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 }
|
|
49 }
|
|
50 }
|