view IniLineParserTest.cs @ 12:0be17f8102ed

* Fix unit test paths
author IBBoard <dev@ibboard.co.uk>
date Wed, 07 Nov 2012 20:22:20 +0000
parents 4f281289bcdd
children
line wrap: on
line source

// This file (IniLineParserTest.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, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.

using System;
using NUnit.Framework;

namespace IBBoard.Ini
{
	[TestFixture()]
	public class IniLineParserTest
	{
		[Test()]
		public void TestIniLineParserReturnsExceptedKeyValuePairForValidProperty()
		{
			IIniLine iniLine = IniLineParser.ParseIniLine("some_key=some_value");
			Assert.IsInstanceOfType(typeof(IniKeyValuePairLine), iniLine);
			IniKeyValuePairLine keyValuePair = (IniKeyValuePairLine)iniLine;
			Assert.AreEqual("some_key", keyValuePair.Key);
			Assert.AreEqual("some_value", keyValuePair.Value);
		}

		
		[Test()]
		public void TestIniLineParserReturnsExceptedKeyValuePairForPaddedValidProperty()
		{
			IIniLine iniLine = IniLineParser.ParseIniLine("   some_key =   some_value  ");
			Assert.IsInstanceOfType(typeof(IniKeyValuePairLine), iniLine);
			IniKeyValuePairLine keyValuePair = (IniKeyValuePairLine)iniLine;
			Assert.AreEqual("some_key", keyValuePair.Key);
			Assert.AreEqual("some_value", keyValuePair.Value);
		}
		
		[Test()]
		public void TestIniLineParserReturnsCommentLineForNonProperty()
		{
			IIniLine iniLine = IniLineParser.ParseIniLine("something that isn't a property");
			Assert.IsInstanceOfType(typeof(IniCommentLine), iniLine);
			IniCommentLine commentLine = (IniCommentLine)iniLine;
			Assert.AreEqual("something that isn't a property", commentLine.Comment);
		}
		
		[Test()]
		public void TestIniLineParserReturnsCommentForComment()
		{
			IIniLine iniLine = IniLineParser.ParseIniLine("; something that looks like a comment");
			Assert.IsInstanceOfType(typeof(IniCommentLine), iniLine);
			IniCommentLine commentLine = (IniCommentLine)iniLine;
			Assert.AreEqual(" something that looks like a comment", commentLine.Comment);
		}
	}
}