Mercurial > repos > IBBoard.Ini.Tests
diff IniSectionTest.cs @ 4:59186ab49249
Re #7 - Add testing of INI parsing
* Add section testing
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 18 Jan 2009 14:18:33 +0000 |
parents | |
children | 4f281289bcdd |
line wrap: on
line diff
--- /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); + } + } +}