Mercurial > repos > IBBoard.Ini.Tests
view IniLineParserTest.cs @ 2:f880d41804d6
Re #7 - Tests for INI parsing
* Add tests for padding at start of file
* Add tests for consecutive sections with no content
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 14 Jan 2009 20:25:58 +0000 |
parents | c2a0d074b3b5 |
children | 4f281289bcdd |
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. 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); } } }