Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to NUnit 3 #142

Merged
merged 6 commits into from Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ solution: src/INIFileParser.sln
script:
- nuget restore src/INIFileParser.sln
- xbuild src/INIFileParser.sln /nologo /verbosity:normal /p:Configuration=Release
- mono ./src/packages/NUnit.Runners.2.6.4/tools/nunit-console.exe -noxml -nodots -labels ./src/IniFileParser.Tests/bin/Release/IniFileParser.Tests.dll
- mono ./src/packages/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe --noresult --labels=All ./src/IniFileParser.Tests/bin/Release/IniFileParser.Tests.dll
mono:
- latest
- 3.12.0
19 changes: 9 additions & 10 deletions src/IniFileParser.Tests/INIFileParser.Tests.csproj
Expand Up @@ -54,12 +54,15 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="NUnit.System.Linq, Version=0.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.1\lib\net20\NUnit.System.Linq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Unit\Configuration\ConfigurationTests.cs" />
Expand All @@ -79,10 +82,8 @@
<Compile Include="Unit\Parser\StringIniDataParserTests.cs" />
<Compile Include="Unit\Model\IniDataCaseInsensitiveTests.cs" />
<Compile Include="Unit\Parser\ConcatenateDuplicatedKeysIniDataParserTests.cs" />
<Compile Include="..\IniFileParser\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="Unit\Model\KeyDataCollectionTests.cs" />
<Compile Include="Unit\TestsSetup.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IniFileParser\INIFileParser.csproj">
Expand All @@ -103,13 +104,13 @@
<None Include="Issue11_example.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="aircraft.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="aircraft2.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="unicode_chinese.ini">
<Link>unicode_chinese.ini</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -141,7 +142,5 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup />
</Project>
@@ -1,4 +1,4 @@
using System;
using System;
using IniParser.Model;
using IniParser.Model.Configuration;
using IniParser.Parser;
Expand Down
9 changes: 3 additions & 6 deletions src/IniFileParser.Tests/Unit/IniParserFile_Test.cs
Expand Up @@ -53,10 +53,9 @@ public void CheckParseGoodFileSuccess()
}

[Test, Description("Checks error when parsing a bad formed INI file")]
[ExpectedException(typeof(ParsingException))]
public void CheckParsingFailure()
{
iniParser.ReadFile(strBadINIFilePath);
Assert.Throws<ParsingException>(() => iniParser.ReadFile(strBadINIFilePath));
}

[Test, Description("Checks correct saving of a file")]
Expand All @@ -71,17 +70,15 @@ public void CheckCorrectSave()
}

[Test, Description("Checks bad formed INI file: Two sections with same name")]
[ExpectedException(typeof(ParsingException))]
public void CheckCollideSectionNames()
{
iniParser.ReadFile(strBadSectionINIFilePath);
Assert.Throws<ParsingException>(() => iniParser.ReadFile(strBadSectionINIFilePath));
}

[Test, Description("Checks bad formed INI file: Two keys in the same section with same name")]
[ExpectedException(typeof(ParsingException))]
public void CheckCollideKeysNames()
{
iniParser.ReadFile(strBadKeysINIFilePath);
Assert.Throws<ParsingException>(() => iniParser.ReadFile(strBadKeysINIFilePath));
}
}
}
34 changes: 17 additions & 17 deletions src/IniFileParser.Tests/Unit/IniParserRegex_Test.cs
@@ -1,4 +1,4 @@
using System;
using System;
using NUnit.Framework;
using IniParser;

Expand All @@ -9,7 +9,7 @@ public class IniParserRegexTest
{
public StreamIniDataParser iniParser = new StreamIniDataParser();

[TestFixtureSetUp]
[OneTimeSetUp]
public void Init()
{
Console.WriteLine(iniParser.Parser.Configuration.Scheme.SectionRegex);
Expand All @@ -25,10 +25,10 @@ public void TestCommentRegex()
string strGoodTest3 = " ; comment Test ";
string strGoodTest4 = " dfasdfasf ; comment Test ";

Assert.That(strGoodTest1, Is.StringMatching(iniParser.Parser.Configuration.CommentRegex.ToString()));
Assert.That(strGoodTest2, !Is.StringMatching(iniParser.Parser.Configuration.CommentRegex.ToString()));
Assert.That(strGoodTest3, !Is.StringMatching(iniParser.Parser.Configuration.CommentRegex.ToString()));
Assert.That(strGoodTest4, !Is.StringMatching(iniParser.Parser.Configuration.CommentRegex.ToString()));
Assert.That(strGoodTest1, Does.Match(iniParser.Parser.Configuration.Scheme.CommentRegex.ToString()));
Assert.That(strGoodTest2, Does.Not.Match(iniParser.Parser.Configuration.Scheme.CommentRegex.ToString()));
Assert.That(strGoodTest3, Does.Not.Match(iniParser.Parser.Configuration.Scheme.CommentRegex.ToString()));
Assert.That(strGoodTest4, Does.Not.Match(iniParser.Parser.Configuration.Scheme.CommentRegex.ToString()));
}

[Test, Description("Test a regular expression for matching a section in an INI file")]
Expand All @@ -45,13 +45,13 @@ public void TestSectionRegex()
string strBadTest1 = " bad [section]";
string strBadTest2 = "[section] bad";

Assert.That(strGoodTest1, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest2, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest3, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest4, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest1, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest2, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest3, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest4, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));

Assert.That(strBadTest1, Is.Not.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest2, Is.Not.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest1, Does.Not.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest2, Does.Not.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
}

[Test, Description("Test a regular expression for matching a section in an INI file given an specific delimiter")]
Expand All @@ -70,12 +70,12 @@ public void TestNewSectionDelimiter()
string strBadTest2 = "<section> bad";


Assert.That(strGoodTest1, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest2, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest3, Is.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest1, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest2, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strGoodTest3, Does.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));

Assert.That(strBadTest1, Is.Not.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest2, Is.Not.StringMatching(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest1, Does.Not.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));
Assert.That(strBadTest2, Does.Not.Match(iniParser.Parser.Configuration.Scheme.SectionRegex.ToString()));

//Restore default delimiters
iniParser.Parser.Configuration.Scheme.SectionStartString = "[";
Expand Down
Expand Up @@ -43,12 +43,10 @@ public void check_cloning()
Assert.That(config2.Scheme.CommentString, Is.EqualTo("/"));
}

// todo: move to keyData tests
[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void create_key_with_invalid_name()
{
new KeyData("");
Assert.Fail("I shouldn't be able to create a section with an empty section name");
Assert.Throws<ArgumentException>(() => new KeyData(""));
}

// todo: move to KeyData tests
Expand Down
15 changes: 7 additions & 8 deletions src/IniFileParser.Tests/Unit/Model/KeyDataTests.cs
Expand Up @@ -19,11 +19,10 @@ public void check_default_values()
Assert.That(kd.Value, Is.Empty);
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void create_key_with_invalid_name()
{
new KeyData("");
Assert.Fail("I shouldn't be able to create a section with an empty section name");
Assert.Throws<ArgumentException>(() => new KeyData(""));
}

[Test]
Expand All @@ -38,7 +37,7 @@ public void creating_keydata_programatically()
KeyData kd = new KeyData(strKeyTest);
kd.Value = strValueTest;
kd.Comments = commentListTest;

//Assert not null and empty
Assert.That(kd, Is.Not.Null);
Assert.That(kd.KeyName, Is.EqualTo(strKeyTest));
Expand Down Expand Up @@ -76,9 +75,9 @@ public void check_deep_clone()
public void check_merge_keys()
{
var keys1 = new KeyDataCollection();
keys1.AddKey( "key1", "value1");
keys1.AddKey( "key2", "value2");
keys1.AddKey( "key3", "value3");
keys1.AddKey("key1", "value1");
keys1.AddKey("key2", "value2");
keys1.AddKey("key3", "value3");

var keys2 = new KeyDataCollection();
keys2.AddKey("key1", "value11");
Expand All @@ -91,7 +90,7 @@ public void check_merge_keys()
Assert.That(keys1["key3"], Is.EqualTo("value3"));
Assert.That(keys1["key4"], Is.EqualTo("value4"));
}

/// <summary>
/// Thanks to h.eriksson@artamir.org for the issue.
/// </summary>
Expand Down
5 changes: 2 additions & 3 deletions src/IniFileParser.Tests/Unit/Model/SectionDataTests.cs
Expand Up @@ -18,11 +18,10 @@ public void check_default_values()
Assert.That(sd.Keys, Is.Empty);
}

[Test, ExpectedException(typeof(ArgumentException))]
[Test]
public void create_section_with_invalid_name()
{
new SectionData("");
Assert.Fail("I shouldn't be able to create a section with an empty section name");
Assert.Throws<ArgumentException>(() => new SectionData(""));
}

[Test]
Expand Down