# HG changeset patch # User IBBoard # Date 1232288313 0 # Node ID 59186ab492496570bfd8d128aad506c4abca4368 # Parent 2d2f4084679f9f20b71266a27e5b5d19a72c2065 Re #7 - Add testing of INI parsing * Add section testing diff -r 2d2f4084679f -r 59186ab49249 IBBoard.Ini.Tests.mdp --- a/IBBoard.Ini.Tests.mdp Sun Jan 18 13:51:47 2009 +0000 +++ b/IBBoard.Ini.Tests.mdp Sun Jan 18 14:18:33 2009 +0000 @@ -25,6 +25,7 @@ + diff -r 2d2f4084679f -r 59186ab49249 IniSectionTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IniSectionTest.cs Sun Jan 18 14:18:33 2009 +0000 @@ -0,0 +1,50 @@ +// This file (IniSectionTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard. +// +// 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. + +using System; +using NUnit.Framework; + +namespace IBBoard.Ini +{ + [TestFixture()] + public class IniSectionTest + { + [Test()] + public void TestAddingCommentLineDoesNotAddKeyItem() + { + IniSection section = new IniSection("someName"); + section.AddIniLine(new IniCommentLine("something")); + Assert.AreEqual(0, section.Keys.Length); + } + + [Test()] + public void TestAddingBlankLineDoesNotAddKeyItem() + { + IniSection section = new IniSection("someName"); + section.AddIniLine(new IniBlankLine()); + Assert.AreEqual(0, section.Keys.Length); + } + + [Test()] + public void TestAddingKeyValuePairLineAddsKeyItem() + { + IniSection section = new IniSection("someName"); + IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); + section.AddIniLine(line); + Assert.AreEqual(1, section.Keys.Length); + Assert.AreEqual(line, section["something"]); + } + + [Test()] + [ExpectedException("IBBoard.Ini.DuplicateIniLineException")] + public void TestAddingKeyValuePairLineExceptionsOnDuplicateKey() + { + IniSection section = new IniSection("someName"); + IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); + section.AddIniLine(line); + line = new IniKeyValuePairLine("something", "different"); + section.AddIniLine(line); + } + } +}