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 wrap: on
line diff
--- a/IBBoard.Ini.Tests.mdp	Sun Jan 18 14:18:33 2009 +0000
+++ b/IBBoard.Ini.Tests.mdp	Sun Jan 18 14:31:09 2009 +0000
@@ -26,6 +26,7 @@
     <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" />
+    <File name="IniFileTest.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/IniFileTest.cs	Sun Jan 18 14:31:09 2009 +0000
@@ -0,0 +1,40 @@
+// This file (IniFileTest.cs) is a part of 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 IniFileTest
+	{		
+		[Test()]
+		public void TestAddingSectionMakesSectionAvailable()
+		{
+			IniFile file = new IniFile();
+			IniSection section = new IniSection("section");
+			file.AddSection(section);
+			Assert.AreEqual(1, file.Sections.Length);
+			Assert.IsTrue(file.HasSection("section"));
+			Assert.AreEqual(section, file["section"]);
+		}
+		
+		[Test()]
+		[ExpectedException("IBBoard.Ini.DuplicateIniSectionException")]
+		public void TestAddingDuplicateSectionThrowsDuplicateSectionException()
+		{
+			IniFile file = new IniFile();
+			file.AddSection(new IniSection("key"));
+			file.AddSection(new IniSection("key"));
+		}
+
+		[Test()]
+		public void TestGettingNonExistantSectionDoesNotReturnNull()
+		{
+			IniFile file = new IniFile();
+			Assert.IsNotNull(file["non-existant-section"]);
+		}
+	}
+}