2 * Copyright (C) 2013 FooProject
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
13 using Microsoft.VisualStudio.TestTools.UnitTesting;
19 public class FoldingCollectionTest
22 public void GetFoldingItem()
24 FoldingCollection collection = new FoldingCollection();
25 collection.Add(new FoldingItem(0, 10));
26 collection.Add(new FoldingItem(1, 5));
27 collection.Add(new FoldingItem(11, 12));
28 FoldingItem item = collection.Get(2, 1);
29 Assert.IsTrue(item.Start == 1 && item.End == 5);
33 public void GetFarestFoldingItem()
35 FoldingCollection collection = new FoldingCollection();
36 FoldingItem item = new FoldingItem(0, 10);
39 collection.Add(new FoldingItem(1, 5));
40 collection.Add(new FoldingItem(11,12));
41 item = collection.GetFarestHiddenFoldingData(2, 1);
42 Assert.IsTrue(item.Start == 0 && item.End == 10);
46 public void GetFoldingItems()
48 FoldingCollection collection = new FoldingCollection();
49 collection.Add(new FoldingItem(0, 10));
50 collection.Add(new FoldingItem(1, 5));
51 collection.Add(new FoldingItem(11, 12));
52 foreach (FoldingItem item in collection.GetRange(0, 10))
53 Assert.IsTrue((item.Start != 11 && item.End != 12));
57 public void CollapseFoldingItem()
59 FoldingCollection collection = new FoldingCollection();
60 FoldingItem newItem = new FoldingItem(0,10);
61 collection.Add(newItem);
62 collection.Add(new FoldingItem(1, 5));
63 collection.Add(new FoldingItem(11, 12));
64 collection.Collapse(newItem);
65 foreach (FoldingItem item in collection.GetRange(0, 10))
66 Assert.IsFalse(item.Expand);
70 public void ExpandFoldingItem()
72 FoldingCollection collection = new FoldingCollection();
73 collection.Add(new FoldingItem(0, 10));
74 FoldingItem newItem = new FoldingItem(1, 5);
75 collection.Add(newItem);
76 collection.Add(new FoldingItem(11, 12));
77 collection.Expand(newItem);
78 foreach (FoldingItem item in collection.GetRange(0, 10))
79 Assert.IsTrue(item.Expand);
83 public void UpdateItems()
85 DummyRender render = new DummyRender();
86 Document doc = new Document(render);
87 FoldingCollection collection = new FoldingCollection();
88 collection.Add(new FoldingItem(0, 10));
89 collection.Add(new FoldingItem(1, 5));
90 collection.Add(new FoldingItem(15, 20));
91 collection.Add(new FoldingItem(16, 17));
92 collection.UpdateData(doc, 11, 1, 0);
93 FoldingItem[] result = collection.GetRange(16, 4).ToArray();
94 Assert.IsTrue((result[0].Start == 16 && result[0].End == 21));
95 Assert.IsTrue((result[1].Start == 17 && result[1].End == 18));
96 collection.UpdateData(doc, 11, 0, 1);
97 result = collection.GetRange(16, 4).ToArray();
98 Assert.IsTrue((result[0].Start == 15 && result[0].End == 20));
99 Assert.IsTrue((result[1].Start == 16 && result[1].End == 17));