Mercurial > repos > IBBoard.Ini.Tests
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 wrap: on
line diff
--- a/IBBoard.Ini.Tests.csproj Sat Feb 21 10:57:23 2009 +0000 +++ b/IBBoard.Ini.Tests.csproj Thu Mar 26 20:13:20 2009 +0000 @@ -45,7 +45,7 @@ <Compile Include="MockIniSectionWithOneLine.cs" /> </ItemGroup> <ItemGroup> - <Folder Include="TestData/" /> + <Folder Include="TestData\" /> </ItemGroup> <ItemGroup> <None Include="TestData\EmptyFile.ini">
--- a/IniFileTest.cs Sat Feb 21 10:57:23 2009 +0000 +++ b/IniFileTest.cs Thu Mar 26 20:13:20 2009 +0000 @@ -29,6 +29,15 @@ file.AddSection(new IniSection("key")); file.AddSection(new IniSection("key")); } + + [Test()] + [ExpectedException("IBBoard.Ini.DuplicateIniSectionException")] + public void TestAddingDuplicateSectionWithDifferentNameCaseThrowsDuplicateSectionException() + { + IniFile file = new IniFile(); + file.AddSection(new IniSection("key")); + file.AddSection(new IniSection("KEY")); + } [Test()] public void TestGettingNonExistantSectionDoesNotReturnNull() @@ -61,6 +70,20 @@ } [Test()] + public void TestGettingSectionLineValueOnLineInSectionWithDifferentSectionNameCaseReturnsValue() + { + IniFile file = new MockIniFileWithOneSectionAndOneLine(); + Assert.AreEqual(MockIniFileWithOneSectionAndOneLine.VALUE, file.GetSectionLineValue(MockIniFileWithOneSectionAndOneLine.SECTION_NAME.ToUpper(), MockIniFileWithOneSectionAndOneLine.KEY_NAME)); + } + + [Test()] + public void TestGettingSectionLineValueOnLineInSectionWithDifferentLineNameCaseReturnsValue() + { + IniFile file = new MockIniFileWithOneSectionAndOneLine(); + Assert.AreEqual(MockIniFileWithOneSectionAndOneLine.VALUE, file.GetSectionLineValue(MockIniFileWithOneSectionAndOneLine.SECTION_NAME, MockIniFileWithOneSectionAndOneLine.KEY_NAME.ToUpper())); + } + + [Test()] public void TestGettingSectionLineValueOnNonExistantSectionReturnsDefaultValue() { IniFile file = new IniFile();
--- a/IniSectionTest.cs Sat Feb 21 10:57:23 2009 +0000 +++ b/IniSectionTest.cs Thu Mar 26 20:13:20 2009 +0000 @@ -48,6 +48,17 @@ } [Test()] + [ExpectedException("IBBoard.Ini.DuplicateIniLineException")] + public void TestAddingKeyValuePairLineExceptionsOnDuplicateKeyWithDifferentCase() + { + IniSection section = new IniSection("someName"); + IniKeyValuePairLine line = new IniKeyValuePairLine("something", "value"); + section.AddIniLine(line); + line = new IniKeyValuePairLine("SOMETHING", "different"); + section.AddIniLine(line); + } + + [Test()] public void TestGettingLineValueOnNonExistantLineReturnsNull() { IniSection section = new MockIniSectionWithOneLine(); @@ -62,6 +73,13 @@ } [Test()] + public void TestGettingSectionLineValueOnLineInSectionWithDifferentCaseReturnsValue() + { + IniSection section = new MockIniSectionWithOneLine(); + Assert.AreEqual(MockIniSectionWithOneLine.VALUE, section.GetLineValue(MockIniSectionWithOneLine.KEY_NAME.ToUpper())); + } + + [Test()] public void TestGettingSectionLineValueOnNonExistantLineInSectionReturnsDefaultValue() { IniSection section = new MockIniSectionWithOneLine();