changeset 5:467e09744775

Closes #7 - Add tests to INI parsing * Add IniFile tests
author IBBoard <dev@ibboard.co.uk>
date Sun, 18 Jan 2009 14:31:09 +0000
parents 59186ab49249
children 4f281289bcdd
files IBBoard.Ini.Tests.mdp IniFileTest.cs
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/IBBoard.Ini.Tests.mdp	Sun Jan 18 14:18:33 2009 +0000
     1.2 +++ b/IBBoard.Ini.Tests.mdp	Sun Jan 18 14:31:09 2009 +0000
     1.3 @@ -26,6 +26,7 @@
     1.4      <File name="TestData/ConsecutiveSection.ini" subtype="Code" buildaction="Nothing" copyToOutputDirectory="PreserveNewest" />
     1.5      <File name="IniSectionParserTest.cs" subtype="Code" buildaction="Compile" />
     1.6      <File name="IniSectionTest.cs" subtype="Code" buildaction="Compile" />
     1.7 +    <File name="IniFileTest.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/IniFileTest.cs	Sun Jan 18 14:31:09 2009 +0000
     2.3 @@ -0,0 +1,40 @@
     2.4 +// This file (IniFileTest.cs) is a part of 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 IniFileTest
    2.15 +	{		
    2.16 +		[Test()]
    2.17 +		public void TestAddingSectionMakesSectionAvailable()
    2.18 +		{
    2.19 +			IniFile file = new IniFile();
    2.20 +			IniSection section = new IniSection("section");
    2.21 +			file.AddSection(section);
    2.22 +			Assert.AreEqual(1, file.Sections.Length);
    2.23 +			Assert.IsTrue(file.HasSection("section"));
    2.24 +			Assert.AreEqual(section, file["section"]);
    2.25 +		}
    2.26 +		
    2.27 +		[Test()]
    2.28 +		[ExpectedException("IBBoard.Ini.DuplicateIniSectionException")]
    2.29 +		public void TestAddingDuplicateSectionThrowsDuplicateSectionException()
    2.30 +		{
    2.31 +			IniFile file = new IniFile();
    2.32 +			file.AddSection(new IniSection("key"));
    2.33 +			file.AddSection(new IniSection("key"));
    2.34 +		}
    2.35 +
    2.36 +		[Test()]
    2.37 +		public void TestGettingNonExistantSectionDoesNotReturnNull()
    2.38 +		{
    2.39 +			IniFile file = new IniFile();
    2.40 +			Assert.IsNotNull(file["non-existant-section"]);
    2.41 +		}
    2.42 +	}
    2.43 +}