Skip to content

Commit

Permalink
update nunit to v3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kbilsted committed Jan 19, 2019
1 parent 6571edd commit f6f65ee
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 28 deletions.
4 changes: 3 additions & 1 deletion StatePrinter.Tests/Configurations/ConfigurationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Internal;
using StatePrinting.Configurations;
using StatePrinting.FieldHarvesters;
using StatePrinting.TestAssistance;
using StatePrinting.ValueConverters;

namespace StatePrinting.Tests.Configurations
Expand Down Expand Up @@ -57,7 +59,7 @@ public void SettingNullValues()
Assert.Throws<ArgumentNullException>(() => sut.AddHandler(t => true, null));
Assert.Throws<ArgumentNullException>(() => sut.AddHandler(null, null));

Assert.Throws<ArgumentNullException>(() => sut.Test.SetAreEqualsMethod(null));
Assert.Throws<ArgumentNullException>(() => sut.Test.SetAreEqualsMethod((TestFrameworkAreEqualsMethod) null));
Assert.Throws<ArgumentNullException>(() => sut.Test.SetAutomaticTestRewrite(null));
}
}
Expand Down
28 changes: 12 additions & 16 deletions StatePrinter.Tests/FieldHarvesters/ProjectionHarvesterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,21 @@ public void AddFilter_OnAlreadyInclude_Success()
}

[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Type A has already been configured as an excluder.")]
public void AddFilter_OnAlreadyExclude_Fail()
{
var harvester = new ProjectionHarvester();
harvester.Exclude<A>(x => x.X);
harvester.AddFilter<A>(x => null);
var ex = Assert.Throws<ArgumentException>(()=>harvester.AddFilter<A>(x => null));
Assert.AreEqual("Type A has already been configured as an excluder.", ex.Message);
}

[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Type A has already been configured as an includer.")]
public void AddFilter_OnAlreadyInclude_Fail()
{
var harvester = new ProjectionHarvester();
harvester.Include<A>(x => x.X);
harvester.AddFilter<A>(x => null);
var ex = Assert.Throws<ArgumentException>(() => harvester.AddFilter<A>(x => null));
Assert.AreEqual("Type A has already been configured as an includer.", ex.Message);
}
}

Expand All @@ -174,12 +174,11 @@ public void WrongSpec_Fail()
}

[Test]
[ExpectedException(typeof(ArgumentException),
ExpectedMessage = "Field 'Year' is declared on type 'DateTime' not on argument: 'A'")]
public void AddExclude_FieldOnDifferentType_Fail()
{
var harvester = new ProjectionHarvester();
harvester.Exclude<A>(x => x.X.Year);
var ex = Assert.Throws<ArgumentException>(() => harvester.Exclude<A>(x => x.X.Year));
Assert.AreEqual("Field 'Year' is declared on type 'DateTime' not on argument: 'A'", ex.Message);
}


Expand Down Expand Up @@ -221,23 +220,21 @@ public void Exclude_FieldInSuperclass_WorksForTypesAndSubtypes()


[Test]
[ExpectedException(typeof(ArgumentException),
ExpectedMessage = "Type A has already been configured as a filter.")]
public void Exclude_OnAlreadyFilter_Fail()
{
var harvester = new ProjectionHarvester();
harvester.AddFilter<A>(x => null);
harvester.Exclude<A>(x => x.X);
var ex = Assert.Throws<ArgumentException>(() => harvester.Exclude<A>(x => x.X));
Assert.AreEqual("Type A has already been configured as a filter.", ex.Message);
}

[Test]
[ExpectedException(typeof(ArgumentException),
ExpectedMessage = "Type A has already been configured as an includer.")]
public void Exclude_OnAlreadyInclude_Fail()
{
var harvester = new ProjectionHarvester();
harvester.Include<A>(x => x.X);
harvester.Exclude<A>(x => x.X);
var ex = Assert.Throws<ArgumentException>(() => harvester.Exclude<A>(x => x.X));
Assert.AreEqual("Type A has already been configured as an includer.", ex.Message);
}
}

Expand All @@ -261,13 +258,12 @@ public void Include_Fieldsarr_WorksForTypesAndSubtypes()
}

[Test]
[ExpectedException(typeof(ArgumentException),
ExpectedMessage = "Type A has already been configured as an excluder.")]
public void Include_OnAlreadyInclude_Fail()
{
var harvester = new ProjectionHarvester();
harvester.Exclude<A>(x => x.X);
harvester.Include<A>(x => x.X);
var ex = Assert.Throws<ArgumentException>(() => harvester.Include<A>(x => x.X));
Assert.AreEqual("Type A has already been configured as an excluder.", ex.Message);
}

interface IF
Expand Down
9 changes: 6 additions & 3 deletions StatePrinter.Tests/StatePrinter.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -14,6 +15,8 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -37,9 +40,8 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.11.0\lib\net35\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -107,6 +109,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
6 changes: 3 additions & 3 deletions StatePrinter.Tests/TestingAssistance/ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

using System;
using NUnit.Framework;
using NUnit.Framework.Internal;
using StatePrinting.TestAssistance;

namespace StatePrinting.Tests.TestingAssistance
{
[TestFixture]
class ParserTest
public class ParserTest
{
Parser sut;

[TestFixtureSetUp]
[SetUp]
public void Setup()
{
sut = new Parser();
Expand Down
7 changes: 4 additions & 3 deletions StatePrinter.Tests/TestingAssistance/ReWriterMockedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace StatePrinting.Tests.TestingAssistance
{
class UserStory_Integration_with_underlying_testing_framework
public class UserStory_Integration_with_underlying_testing_framework
{
[Test]
public void Rewriter_calls_to_testframework_autorewriting()
Expand Down Expand Up @@ -100,11 +100,11 @@ reported by the callstackreflector
5
";


/// <summary>
/// By running again against the same file, the line number has now increased to something larger than the input file
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException), ExpectedMessage = "File does not have 121 lines. Only 47 lines.\r\nParameter name: content")]
public void Rewriter_calls_to_testframework_fileTooShort()
{
var printer = TestHelper.CreateTestPrinter();
Expand All @@ -118,7 +118,8 @@ public void Rewriter_calls_to_testframework_fileTooShort()

string expected = @"expect";

printer.Assert.AreAlike(expected, "actul");
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => printer.Assert.AreAlike(expected, "actul"));
Assert.AreEqual("File does not have 121 lines. Only 47 lines.\r\nParameter name: content", ex.Message);
}
}
}
10 changes: 8 additions & 2 deletions StatePrinter.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BuildTools.StyleCop" version="4.7.49.0" targetFramework="net35" />
<package id="NUnit" version="2.6.4" targetFramework="net35" />
<package id="NUnit.Runners" version="2.6.4" />
<package id="coveralls.io" version="1.1.86" />
<package id="NUnit" version="3.11.0" targetFramework="net35" />
<package id="NUnit.ConsoleRunner" version="3.9.0" targetFramework="net35" />
<package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net35" />
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net35" />
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net35" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.3" targetFramework="net35" />
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net35" />
<package id="NUnit.Runners" version="3.9.0" targetFramework="net35" />
<package id="OpenCover" version="4.5.3522" />
</packages>
12 changes: 12 additions & 0 deletions StatePrinter/Configurations/TestingBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// under the License.

using System;
using System.Data.SqlClient;
using StatePrinting.TestAssistance;

namespace StatePrinting.Configurations
Expand All @@ -44,6 +45,17 @@ public Configuration SetAreEqualsMethod(TestFrameworkAreEqualsMethod areEqualsMe
return configuration;
}

private static readonly object[] NoArg = new object[0];

public Configuration SetAreEqualsMethod(Action<string,string,string,object[]> nunitAreEqualsMethod)
{
if (nunitAreEqualsMethod == null)
throw new ArgumentNullException("nunitAreEqualsMethod");
AreEqualsMethod = new TestFrameworkAreEqualsMethod((actual, expected, message) => nunitAreEqualsMethod(actual,expected,message,NoArg));

return configuration;
}

/// <summary>
/// Configure how to call AreEquals in the unit testing framework of your choice.
/// Only set this field if you are using the <see cref="Stateprinter.Assert"/> functionality.
Expand Down

0 comments on commit f6f65ee

Please sign in to comment.