Mercurial > repos > IBBoard.Ini.Tests
annotate IniFileReaderTest.cs @ 2:f880d41804d6
Re #7 - Tests for INI parsing
* Add tests for padding at start of file
* Add tests for consecutive sections with no content
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 14 Jan 2009 20:25:58 +0000 |
parents | c2a0d074b3b5 |
children | 2d2f4084679f |
rev | line source |
---|---|
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (IniFileReaderTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard. |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license. Please see COPYING.LGPL for more information and the full license. |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.IO; |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using NUnit.Framework; |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 namespace IBBoard.Ini |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 [TestFixture()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 public class IniFileReaderTest |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 [Test()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 public void TestIniFileReaderReturnsEmptyObjectForEmptyIniText() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 IniFile file = IniFileReader.ReadFile(""); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 Assert.AreEqual(0, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 [Test()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniText() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 IniFile file = IniFileReader.ReadFile("[ASection]"); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 Assert.AreEqual(1, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 Assert.IsNotNull(file["ASection"]); |
1 | 29 Assert.AreEqual(0, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 [Test()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniTextWithContent() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 IniFile file = IniFileReader.ReadFile("[ASection]\nsomething=fibble"); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 Assert.AreEqual(1, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 Assert.IsNotNull(file["ASection"]); |
1 | 40 Assert.AreEqual(1, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 [Test()] |
1 | 45 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniTextWithMultiLineContent() |
46 { | |
47 IniFile file = IniFileReader.ReadFile("[ASection]\nsomething=fibble\nfobble_key=foo\nabcde=fghij\nfoo9=bar2"); | |
48 Assert.AreEqual(1, file.Sections.Length); | |
49 Assert.IsTrue(file.HasSection("ASection")); | |
50 IniSection section = file["ASection"]; | |
51 Assert.IsNotNull(section); | |
52 Assert.AreEqual(4, section.Keys.Length); | |
53 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | |
54 | |
55 string[] keys = new string[]{"something", "fobble_key", "abcde", "foo9"}; | |
56 | |
57 foreach (string key in keys) | |
58 { | |
59 bool found = false; | |
60 | |
61 foreach (string sectionKey in section.Keys) | |
62 { | |
63 if (key == sectionKey) | |
64 { | |
65 found = true; | |
66 break; | |
67 } | |
68 } | |
69 | |
70 Assert.IsTrue(found, "Did not find "+key); | |
71 } | |
72 } | |
73 | |
74 [Test()] | |
2 | 75 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniTextWithContent() |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 IniFile file = IniFileReader.ReadFile("[ASection]\nsomething=fibble\n[BSection]\nsomethingElse=fibble"); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 Assert.AreEqual(2, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 Assert.IsNotNull(file["ASection"]); |
1 | 81 Assert.AreEqual(1, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 Assert.IsTrue(file.HasSection("BSection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 Assert.IsNotNull(file["BSection"]); |
1 | 85 Assert.AreEqual(1, file["BSection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["BSection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 [Test()] |
2 | 90 public void TestIniFileReaderContainsExpectedSectionsForTwoConsecutiveSectionSectionsInText() |
91 { | |
92 IniFile file = IniFileReader.ReadFile("[SectionA]\n[SectionB]"); | |
93 Assert.AreEqual(2, file.Sections.Length); | |
94 Assert.IsTrue(file.HasSection("SectionA")); | |
95 Assert.IsNotNull(file["SectionA"]); | |
96 Assert.AreEqual(0, file["SectionA"].Keys.Length); | |
97 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionA"]); | |
98 Assert.IsTrue(file.HasSection("SectionB")); | |
99 Assert.IsNotNull(file["SectionB"]); | |
100 Assert.AreEqual(0, file["SectionB"].Keys.Length); | |
101 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionB"]); | |
102 } | |
103 | |
104 [Test()] | |
105 public void TestIniFileReaderContainsExpectedSectionWhenTextPaddedAtStart() | |
106 { | |
107 IniFile file = IniFileReader.ReadFile("\nnon-blank\n[ASection]\nsomething=fibble"); | |
108 Assert.AreEqual(1, file.Sections.Length); | |
109 Assert.IsTrue(file.HasSection("ASection")); | |
110 Assert.IsNotNull(file["ASection"]); | |
111 Assert.AreEqual(1, file["ASection"].Keys.Length); | |
112 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | |
113 } | |
114 | |
115 [Test()] | |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 public void TestIniFileReaderReturnsEmptyObjectForEmptyIniFile() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 IniFile file = IniFileReader.ReadFile(new FileInfo("EmptyFile.ini")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 Assert.AreEqual(0, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 [Test()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFile() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionSingleLine.ini")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 Assert.AreEqual(1, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 Assert.IsNotNull(file["ASection"]); |
1 | 130 Assert.AreEqual(0, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 [Test()] |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithContent() |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionWithContent.ini")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 Assert.AreEqual(1, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 Assert.IsNotNull(file["ASection"]); |
1 | 141 Assert.AreEqual(1, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 [Test()] |
2 | 146 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniFileWithContent() |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 { |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 IniFile file = IniFileReader.ReadFile(new FileInfo("DoubleSectionWithContent.ini")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 Assert.AreEqual(2, file.Sections.Length); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
150 Assert.IsTrue(file.HasSection("ASection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
151 Assert.IsNotNull(file["ASection"]); |
1 | 152 Assert.AreEqual(1, file["ASection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
153 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
154 Assert.IsTrue(file.HasSection("BSection")); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
155 Assert.IsNotNull(file["BSection"]); |
1 | 156 Assert.AreEqual(1, file["BSection"].Keys.Length); |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["BSection"]); |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 } |
1 | 159 |
160 [Test()] | |
161 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithMultiLineContent() | |
162 { | |
163 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionWithMultiLineContent.ini")); | |
164 Assert.AreEqual(1, file.Sections.Length); | |
165 Assert.IsTrue(file.HasSection("ASection")); | |
166 IniSection section = file["ASection"]; | |
167 Assert.IsNotNull(section); | |
168 Assert.AreEqual(4, section.Keys.Length); | |
169 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | |
170 | |
171 string[] keys = new string[]{"something", "fobble_key", "abcde", "foo9"}; | |
172 | |
173 foreach (string key in keys) | |
174 { | |
175 bool found = false; | |
176 | |
177 foreach (string sectionKey in section.Keys) | |
178 { | |
179 if (key == sectionKey) | |
180 { | |
181 found = true; | |
182 break; | |
183 } | |
184 } | |
185 | |
186 Assert.IsTrue(found, "Did not find "+key); | |
187 } | |
188 } | |
2 | 189 |
190 [Test()] | |
191 public void TestIniFileReaderContainsExpectedSectionWhenFilePaddedAtStart() | |
192 { | |
193 IniFile file = IniFileReader.ReadFile(new FileInfo("StartPadded.ini")); | |
194 Assert.AreEqual(1, file.Sections.Length); | |
195 Assert.IsTrue(file.HasSection("ASection")); | |
196 Assert.IsNotNull(file["ASection"]); | |
197 Assert.AreEqual(1, file["ASection"].Keys.Length); | |
198 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | |
199 } | |
200 | |
201 [Test()] | |
202 public void TestIniFileReaderContainsExpectedSectionsForTwoConsecutiveSectionSectionsInFile() | |
203 { | |
204 IniFile file = IniFileReader.ReadFile(new FileInfo("ConsecutiveSection.ini")); | |
205 Assert.AreEqual(2, file.Sections.Length); | |
206 Assert.IsTrue(file.HasSection("SectionA")); | |
207 Assert.IsNotNull(file["SectionA"]); | |
208 Assert.AreEqual(0, file["SectionA"].Keys.Length); | |
209 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionA"]); | |
210 Assert.IsTrue(file.HasSection("SectionB")); | |
211 Assert.IsNotNull(file["SectionB"]); | |
212 Assert.AreEqual(0, file["SectionB"].Keys.Length); | |
213 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionB"]); | |
214 } | |
0
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 } |
ada654b0648c
Re #7 - add IBBoard.Ini test\n * Add initial tests
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 } |