Mercurial > repos > IBBoard.Ini.Tests
comparison IniFileReaderTest.cs @ 12:0be17f8102ed
* Fix unit test paths
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 07 Nov 2012 20:22:20 +0000 |
parents | 4f281289bcdd |
children |
comparison
equal
deleted
inserted
replaced
11:c7e381ba537a | 12:0be17f8102ed |
---|---|
1 // This file (IniFileReaderTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard. | 1 // This file (IniFileReaderTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard. |
2 // | 2 // |
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. | 3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
4 | |
5 using System; | 4 using System; |
6 using System.IO; | 5 using System.IO; |
7 using NUnit.Framework; | 6 using NUnit.Framework; |
8 | 7 |
9 namespace IBBoard.Ini | 8 namespace IBBoard.Ini |
64 found = true; | 63 found = true; |
65 break; | 64 break; |
66 } | 65 } |
67 } | 66 } |
68 | 67 |
69 Assert.IsTrue(found, "Did not find "+key); | 68 Assert.IsTrue(found, "Did not find " + key); |
70 } | 69 } |
71 } | 70 } |
72 | 71 |
73 [Test()] | 72 [Test()] |
74 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniTextWithContent() | 73 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniTextWithContent() |
112 } | 111 } |
113 | 112 |
114 [Test()] | 113 [Test()] |
115 public void TestIniFileReaderReturnsEmptyObjectForEmptyIniFile() | 114 public void TestIniFileReaderReturnsEmptyObjectForEmptyIniFile() |
116 { | 115 { |
117 IniFile file = IniFileReader.ReadFile(new FileInfo("EmptyFile.ini")); | 116 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/EmptyFile.ini")); |
118 Assert.AreEqual(0, file.Sections.Length); | 117 Assert.AreEqual(0, file.Sections.Length); |
119 } | 118 } |
120 | |
121 | 119 |
122 [Test()] | 120 [Test()] |
123 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFile() | 121 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFile() |
124 { | 122 { |
125 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionSingleLine.ini")); | 123 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/SingleSectionSingleLine.ini")); |
126 Assert.AreEqual(1, file.Sections.Length); | 124 Assert.AreEqual(1, file.Sections.Length); |
127 Assert.IsTrue(file.HasSection("ASection")); | 125 Assert.IsTrue(file.HasSection("ASection")); |
128 Assert.IsNotNull(file["ASection"]); | 126 Assert.IsNotNull(file["ASection"]); |
129 Assert.AreEqual(0, file["ASection"].Keys.Length); | 127 Assert.AreEqual(0, file["ASection"].Keys.Length); |
130 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | 128 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
131 } | 129 } |
132 | 130 |
133 [Test()] | 131 [Test()] |
134 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithContent() | 132 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithContent() |
135 { | 133 { |
136 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionWithContent.ini")); | 134 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/SingleSectionWithContent.ini")); |
137 Assert.AreEqual(1, file.Sections.Length); | 135 Assert.AreEqual(1, file.Sections.Length); |
138 Assert.IsTrue(file.HasSection("ASection")); | 136 Assert.IsTrue(file.HasSection("ASection")); |
139 Assert.IsNotNull(file["ASection"]); | 137 Assert.IsNotNull(file["ASection"]); |
140 Assert.AreEqual(1, file["ASection"].Keys.Length); | 138 Assert.AreEqual(1, file["ASection"].Keys.Length); |
141 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | 139 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
142 } | 140 } |
143 | 141 |
144 [Test()] | 142 [Test()] |
145 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniFileWithContent() | 143 public void TestIniFileReaderContainsExpectedSectionsForTwoSectionIniFileWithContent() |
146 { | 144 { |
147 IniFile file = IniFileReader.ReadFile(new FileInfo("DoubleSectionWithContent.ini")); | 145 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/DoubleSectionWithContent.ini")); |
148 Assert.AreEqual(2, file.Sections.Length); | 146 Assert.AreEqual(2, file.Sections.Length); |
149 Assert.IsTrue(file.HasSection("ASection")); | 147 Assert.IsTrue(file.HasSection("ASection")); |
150 Assert.IsNotNull(file["ASection"]); | 148 Assert.IsNotNull(file["ASection"]); |
151 Assert.AreEqual(1, file["ASection"].Keys.Length); | 149 Assert.AreEqual(1, file["ASection"].Keys.Length); |
152 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | 150 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
157 } | 155 } |
158 | 156 |
159 [Test()] | 157 [Test()] |
160 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithMultiLineContent() | 158 public void TestIniFileReaderContainsExpectedSectionForSingleSectionIniFileWithMultiLineContent() |
161 { | 159 { |
162 IniFile file = IniFileReader.ReadFile(new FileInfo("SingleSectionWithMultiLineContent.ini")); | 160 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/SingleSectionWithMultiLineContent.ini")); |
163 Assert.AreEqual(1, file.Sections.Length); | 161 Assert.AreEqual(1, file.Sections.Length); |
164 Assert.IsTrue(file.HasSection("ASection")); | 162 Assert.IsTrue(file.HasSection("ASection")); |
165 IniSection section = file["ASection"]; | 163 IniSection section = file["ASection"]; |
166 Assert.IsNotNull(section); | 164 Assert.IsNotNull(section); |
167 Assert.AreEqual(4, section.Keys.Length); | 165 Assert.AreEqual(4, section.Keys.Length); |
180 found = true; | 178 found = true; |
181 break; | 179 break; |
182 } | 180 } |
183 } | 181 } |
184 | 182 |
185 Assert.IsTrue(found, "Did not find "+key); | 183 Assert.IsTrue(found, "Did not find " + key); |
186 } | 184 } |
187 } | 185 } |
188 | 186 |
189 [Test()] | 187 [Test()] |
190 public void TestIniFileReaderContainsExpectedSectionWhenFilePaddedAtStart() | 188 public void TestIniFileReaderContainsExpectedSectionWhenFilePaddedAtStart() |
191 { | 189 { |
192 IniFile file = IniFileReader.ReadFile(new FileInfo("StartPadded.ini")); | 190 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/StartPadded.ini")); |
193 Assert.AreEqual(1, file.Sections.Length); | 191 Assert.AreEqual(1, file.Sections.Length); |
194 Assert.IsTrue(file.HasSection("ASection")); | 192 Assert.IsTrue(file.HasSection("ASection")); |
195 Assert.IsNotNull(file["ASection"]); | 193 Assert.IsNotNull(file["ASection"]); |
196 Assert.AreEqual(1, file["ASection"].Keys.Length); | 194 Assert.AreEqual(1, file["ASection"].Keys.Length); |
197 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); | 195 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["ASection"]); |
198 } | 196 } |
199 | 197 |
200 [Test()] | 198 [Test()] |
201 public void TestIniFileReaderContainsExpectedSectionsForTwoConsecutiveSectionSectionsInFile() | 199 public void TestIniFileReaderContainsExpectedSectionsForTwoConsecutiveSectionSectionsInFile() |
202 { | 200 { |
203 IniFile file = IniFileReader.ReadFile(new FileInfo("ConsecutiveSection.ini")); | 201 IniFile file = IniFileReader.ReadFile(new FileInfo("TestData/ConsecutiveSection.ini")); |
204 Assert.AreEqual(2, file.Sections.Length); | 202 Assert.AreEqual(2, file.Sections.Length); |
205 Assert.IsTrue(file.HasSection("SectionA")); | 203 Assert.IsTrue(file.HasSection("SectionA")); |
206 Assert.IsNotNull(file["SectionA"]); | 204 Assert.IsNotNull(file["SectionA"]); |
207 Assert.AreEqual(0, file["SectionA"].Keys.Length); | 205 Assert.AreEqual(0, file["SectionA"].Keys.Length); |
208 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionA"]); | 206 Assert.IsNotInstanceOfType(typeof(NonExistantIniSection), file["SectionA"]); |