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 diff
     1.1 --- a/IBBoard.Ini.Tests.mdp	Sun Jan 18 13:51:47 2009 +0000
     1.2 +++ b/IBBoard.Ini.Tests.mdp	Sun Jan 18 14:18:33 2009 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4      <File name="TestData/StartPadded.ini" subtype="Code" buildaction="Nothing" copyToOutputDirectory="PreserveNewest" />
     1.5      <File name="TestData/ConsecutiveSection.ini" subtype="Code" buildaction="Nothing" copyToOutputDirectory="PreserveNewest" />
     1.6      <File name="IniSectionParserTest.cs" subtype="Code" buildaction="Compile" />
     1.7 +    <File name="IniSectionTest.cs" subtype="Code" buildaction="Compile" />
     1.8    </Contents>
     1.9    <References>
    1.10      <ProjectReference type="Project" localcopy="True" refto="IBBoard.Ini" />
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/IniSectionTest.cs	Sun Jan 18 14:18:33 2009 +0000
     2.3 @@ -0,0 +1,50 @@
     2.4 +// This file (IniSectionTest.cs) is a part of the IBBoard.Ini.Tests library and is copyright 2009 IBBoard.
     2.5 +//
     2.6 +// 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.
     2.7 +
     2.8 +using System;
     2.9 +using NUnit.Framework;
    2.10 +
    2.11 +namespace IBBoard.Ini
    2.12 +{
    2.13 +	[TestFixture()]
    2.14 +	public class IniSectionTest
    2.15 +	{
    2.16 +		[Test()]
    2.17 +		public void TestAddingCommentLineDoesNotAddKeyItem()
    2.18 +		{
    2.19 +			IniSection section = new IniSection("someName");
    2.20 +			section.AddIniLine(new IniCommentLine("something"));
    2.21 +			Assert.AreEqual(0, section.Keys.Length);
    2.22 +		}
    2.23 +		
    2.24 +		[Test()]
    2.25 +		public void TestAddingBlankLineDoesNotAddKeyItem()
    2.26 +		{
    2.27 +			IniSection section = new IniSection("someName");
    2.28 +			section.AddIniLine(new IniBlankLine());
    2.29 +			Assert.AreEqual(0, section.Keys.Length);
    2.30 +		}
    2.31 +		
    2.32 +		[Test()]
    2.33 +		public void TestAddingKeyValuePairLineAddsKeyItem()
    2.34 +		{
    2.35 +			IniSection section = new IniSection("someName");
    2.36 +			IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value");
    2.37 +			section.AddIniLine(line);
    2.38 +			Assert.AreEqual(1, section.Keys.Length);
    2.39 +			Assert.AreEqual(line, section["something"]);
    2.40 +		}
    2.41 +		
    2.42 +		[Test()]
    2.43 +		[ExpectedException("IBBoard.Ini.DuplicateIniLineException")]
    2.44 +		public void TestAddingKeyValuePairLineExceptionsOnDuplicateKey()
    2.45 +		{
    2.46 +			IniSection section = new IniSection("someName");
    2.47 +			IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value");
    2.48 +			section.AddIniLine(line);
    2.49 +			line = new IniKeyValuePairLine("something", "different");
    2.50 +			section.AddIniLine(line);
    2.51 +		}
    2.52 +	}
    2.53 +}