Mercurial > repos > IBBoard.Ini.Tests
annotate IniSectionTest.cs @ 12:0be17f8102ed
* Fix unit test paths
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 07 Nov 2012 20:22:20 +0000 |
parents | 62221475c572 |
children |
rev | line source |
---|---|
4 | 1 // This file (IniSectionTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard. |
2 // | |
6 | 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 | 4 |
5 using System; | |
6 using NUnit.Framework; | |
7 | |
8 namespace IBBoard.Ini | |
9 { | |
10 [TestFixture()] | |
11 public class IniSectionTest | |
12 { | |
13 [Test()] | |
14 public void TestAddingCommentLineDoesNotAddKeyItem() | |
15 { | |
16 IniSection section = new IniSection("someName"); | |
17 section.AddIniLine(new IniCommentLine("something")); | |
18 Assert.AreEqual(0, section.Keys.Length); | |
19 } | |
20 | |
21 [Test()] | |
22 public void TestAddingBlankLineDoesNotAddKeyItem() | |
23 { | |
24 IniSection section = new IniSection("someName"); | |
25 section.AddIniLine(new IniBlankLine()); | |
26 Assert.AreEqual(0, section.Keys.Length); | |
27 } | |
28 | |
29 [Test()] | |
30 public void TestAddingKeyValuePairLineAddsKeyItem() | |
31 { | |
32 IniSection section = new IniSection("someName"); | |
33 IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); | |
34 section.AddIniLine(line); | |
35 Assert.AreEqual(1, section.Keys.Length); | |
36 Assert.AreEqual(line, section["something"]); | |
37 } | |
38 | |
39 [Test()] | |
40 [ExpectedException("IBBoard.Ini.DuplicateIniLineException")] | |
41 public void TestAddingKeyValuePairLineExceptionsOnDuplicateKey() | |
42 { | |
43 IniSection section = new IniSection("someName"); | |
44 IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); | |
45 section.AddIniLine(line); | |
46 line = new IniKeyValuePairLine("something", "different"); | |
47 section.AddIniLine(line); | |
48 } | |
9
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
49 |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
50 [Test()] |
10
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
51 [ExpectedException("IBBoard.Ini.DuplicateIniLineException")] |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
52 public void TestAddingKeyValuePairLineExceptionsOnDuplicateKeyWithDifferentCase() |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
53 { |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
54 IniSection section = new IniSection("someName"); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
55 IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
56 section.AddIniLine(line); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
57 line = new IniKeyValuePairLine("SOMETHING", "different"); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
58 section.AddIniLine(line); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
59 } |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
60 |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
61 [Test()] |
9
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
62 public void TestGettingLineValueOnNonExistantLineReturnsNull() |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
63 { |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
64 IniSection section = new MockIniSectionWithOneLine(); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
65 Assert.IsNull(section.GetLineValue("b")); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
66 } |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
67 |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
68 [Test()] |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
69 public void TestGettingSectionLineValueOnLineInSectionReturnsValue() |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
70 { |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
71 IniSection section = new MockIniSectionWithOneLine(); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
72 Assert.AreEqual(MockIniSectionWithOneLine.VALUE, section.GetLineValue(MockIniSectionWithOneLine.KEY_NAME)); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
73 } |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
74 |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
75 [Test()] |
10
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
76 public void TestGettingSectionLineValueOnLineInSectionWithDifferentCaseReturnsValue() |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
77 { |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
78 IniSection section = new MockIniSectionWithOneLine(); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
79 Assert.AreEqual(MockIniSectionWithOneLine.VALUE, section.GetLineValue(MockIniSectionWithOneLine.KEY_NAME.ToUpper())); |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
80 } |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
81 |
62221475c572
Fixes #17 - Make INI section and keys case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
9
diff
changeset
|
82 [Test()] |
9
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
83 public void TestGettingSectionLineValueOnNonExistantLineInSectionReturnsDefaultValue() |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
84 { |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
85 IniSection section = new MockIniSectionWithOneLine(); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
86 Assert.AreEqual("default-value", section.GetLineValue("b", "default-value")); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
87 } |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
88 |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
89 [Test()] |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
90 public void TestGettingSectionLineValueOnLineInSectionDoesNotReturnDefault() |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
91 { |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
92 IniSection section = new MockIniSectionWithOneLine(); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
93 Assert.AreEqual(MockIniSectionWithOneLine.VALUE, section.GetLineValue(MockIniSectionWithOneLine.KEY_NAME, "default-value")); |
eac501db18e7
Re #11 - Add getter methods to IniFile and IniSection
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
94 } |
4 | 95 } |
96 } |