changeset 10:62221475c572

Fixes #17 - Make INI section and keys case-insensitive * Add tests to make sure that the keys and names are treated as case-insensitive
author IBBoard <dev@ibboard.co.uk>
date Thu, 26 Mar 2009 20:13:20 +0000
parents eac501db18e7
children c7e381ba537a
files IBBoard.Ini.Tests.csproj IniFileTest.cs IniSectionTest.cs
diffstat 3 files changed, 42 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/IBBoard.Ini.Tests.csproj	Sat Feb 21 10:57:23 2009 +0000
     1.2 +++ b/IBBoard.Ini.Tests.csproj	Thu Mar 26 20:13:20 2009 +0000
     1.3 @@ -45,7 +45,7 @@
     1.4      <Compile Include="MockIniSectionWithOneLine.cs" />
     1.5    </ItemGroup>
     1.6    <ItemGroup>
     1.7 -    <Folder Include="TestData/" />
     1.8 +    <Folder Include="TestData\" />
     1.9    </ItemGroup>
    1.10    <ItemGroup>
    1.11      <None Include="TestData\EmptyFile.ini">
     2.1 --- a/IniFileTest.cs	Sat Feb 21 10:57:23 2009 +0000
     2.2 +++ b/IniFileTest.cs	Thu Mar 26 20:13:20 2009 +0000
     2.3 @@ -29,6 +29,15 @@
     2.4  			file.AddSection(new IniSection("key"));
     2.5  			file.AddSection(new IniSection("key"));
     2.6  		}
     2.7 +		
     2.8 +		[Test()]
     2.9 +		[ExpectedException("IBBoard.Ini.DuplicateIniSectionException")]
    2.10 +		public void TestAddingDuplicateSectionWithDifferentNameCaseThrowsDuplicateSectionException()
    2.11 +		{
    2.12 +			IniFile file = new IniFile();
    2.13 +			file.AddSection(new IniSection("key"));
    2.14 +			file.AddSection(new IniSection("KEY"));
    2.15 +		}
    2.16  
    2.17  		[Test()]
    2.18  		public void TestGettingNonExistantSectionDoesNotReturnNull()
    2.19 @@ -61,6 +70,20 @@
    2.20  		}
    2.21  		
    2.22  		[Test()]
    2.23 +		public void TestGettingSectionLineValueOnLineInSectionWithDifferentSectionNameCaseReturnsValue()
    2.24 +		{
    2.25 +			IniFile file = new MockIniFileWithOneSectionAndOneLine();
    2.26 +			Assert.AreEqual(MockIniFileWithOneSectionAndOneLine.VALUE, file.GetSectionLineValue(MockIniFileWithOneSectionAndOneLine.SECTION_NAME.ToUpper(), MockIniFileWithOneSectionAndOneLine.KEY_NAME));
    2.27 +		}
    2.28 +		
    2.29 +		[Test()]
    2.30 +		public void TestGettingSectionLineValueOnLineInSectionWithDifferentLineNameCaseReturnsValue()
    2.31 +		{
    2.32 +			IniFile file = new MockIniFileWithOneSectionAndOneLine();
    2.33 +			Assert.AreEqual(MockIniFileWithOneSectionAndOneLine.VALUE, file.GetSectionLineValue(MockIniFileWithOneSectionAndOneLine.SECTION_NAME, MockIniFileWithOneSectionAndOneLine.KEY_NAME.ToUpper()));
    2.34 +		}
    2.35 +		
    2.36 +		[Test()]
    2.37  		public void TestGettingSectionLineValueOnNonExistantSectionReturnsDefaultValue()
    2.38  		{
    2.39  			IniFile file = new IniFile();
     3.1 --- a/IniSectionTest.cs	Sat Feb 21 10:57:23 2009 +0000
     3.2 +++ b/IniSectionTest.cs	Thu Mar 26 20:13:20 2009 +0000
     3.3 @@ -48,6 +48,17 @@
     3.4  		}
     3.5  		
     3.6  		[Test()]
     3.7 +		[ExpectedException("IBBoard.Ini.DuplicateIniLineException")]
     3.8 +		public void TestAddingKeyValuePairLineExceptionsOnDuplicateKeyWithDifferentCase()
     3.9 +		{
    3.10 +			IniSection section = new IniSection("someName");
    3.11 +			IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value");
    3.12 +			section.AddIniLine(line);
    3.13 +			line = new IniKeyValuePairLine("SOMETHING", "different");
    3.14 +			section.AddIniLine(line);
    3.15 +		}
    3.16 +		
    3.17 +		[Test()]
    3.18  		public void TestGettingLineValueOnNonExistantLineReturnsNull()
    3.19  		{
    3.20  			IniSection section = new MockIniSectionWithOneLine();
    3.21 @@ -62,6 +73,13 @@
    3.22  		}
    3.23  		
    3.24  		[Test()]
    3.25 +		public void TestGettingSectionLineValueOnLineInSectionWithDifferentCaseReturnsValue()
    3.26 +		{
    3.27 +			IniSection section = new MockIniSectionWithOneLine();
    3.28 +			Assert.AreEqual(MockIniSectionWithOneLine.VALUE, section.GetLineValue(MockIniSectionWithOneLine.KEY_NAME.ToUpper()));
    3.29 +		}
    3.30 +		
    3.31 +		[Test()]
    3.32  		public void TestGettingSectionLineValueOnNonExistantLineInSectionReturnsDefaultValue()
    3.33  		{
    3.34  			IniSection section = new MockIniSectionWithOneLine();