Mercurial > repos > IBBoard.Ini.Tests
changeset 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 | 2d2f4084679f |
children | 467e09744775 |
files | IBBoard.Ini.Tests.mdp IniSectionTest.cs |
diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ <File name="TestData/StartPadded.ini" subtype="Code" buildaction="Nothing" copyToOutputDirectory="PreserveNewest" /> <File name="TestData/ConsecutiveSection.ini" subtype="Code" buildaction="Nothing" copyToOutputDirectory="PreserveNewest" /> <File name="IniSectionParserTest.cs" subtype="Code" buildaction="Compile" /> + <File name="IniSectionTest.cs" subtype="Code" buildaction="Compile" /> </Contents> <References> <ProjectReference type="Project" localcopy="True" refto="IBBoard.Ini" />
--- /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); + } + } +}