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

Replace Moq with NSubstitute #21

Merged
merged 1 commit into from
Aug 10, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions NHamcrest.sln
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
# Visual Studio Version 17
VisualStudioVersion = 17.7.34003.232
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NUnit", "NUnit", "{9985B589-EC67-4FE7-83A1-3A68959CAAAC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XUnit", "XUnit", "{0EE42F24-2D10-425F-814F-F2C67431C5B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest.NUnit", "src\NHamcrest.NUnit\NHamcrest.NUnit.csproj", "{ED5F34C9-D815-46CD-BAC2-AC62A795894B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest.NUnit", "src\NHamcrest.NUnit\NHamcrest.NUnit.csproj", "{ED5F34C9-D815-46CD-BAC2-AC62A795894B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest.NUnit.Examples", "src\NHamcrest.NUnit.Examples\NHamcrest.NUnit.Examples.csproj", "{3047BC0C-DD71-4EC8-9835-15B9A41B2C62}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest.NUnit.Examples", "src\NHamcrest.NUnit.Examples\NHamcrest.NUnit.Examples.csproj", "{3047BC0C-DD71-4EC8-9835-15B9A41B2C62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest.XUnit", "src\NHamcrest.XUnit\NHamcrest.XUnit.csproj", "{235F5147-DCDC-439C-9220-DF2E5FB23F66}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest.XUnit", "src\NHamcrest.XUnit\NHamcrest.XUnit.csproj", "{235F5147-DCDC-439C-9220-DF2E5FB23F66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest.XUnit.Examples", "src\NHamcrest.XUnit.Examples\NHamcrest.XUnit.Examples.csproj", "{FB567185-A872-4D8E-A4C5-CC3D4430D7DF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest.XUnit.Examples", "src\NHamcrest.XUnit.Examples\NHamcrest.XUnit.Examples.csproj", "{FB567185-A872-4D8E-A4C5-CC3D4430D7DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest", "src\NHamcrest\NHamcrest.csproj", "{BF7E7EB3-0C15-4F55-85F9-B2A7564D98D4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest", "src\NHamcrest\NHamcrest.csproj", "{BF7E7EB3-0C15-4F55-85F9-B2A7564D98D4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHamcrest.Tests", "src\NHamcrest.Tests\NHamcrest.Tests.csproj", "{368D7391-0C63-4F48-8D8C-3942E0693B92}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHamcrest.Tests", "src\NHamcrest.Tests\NHamcrest.Tests.csproj", "{368D7391-0C63-4F48-8D8C-3942E0693B92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6554B7FF-2FE4-44AC-A33A-730FC30A0728}"
ProjectSection(SolutionItems) = preProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions src/NHamcrest.Tests/Core/AnyOfTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NHamcrest.Core;
using System;
using System.Collections.Generic;

using NHamcrest.Core;
using Xunit;

namespace NHamcrest.Tests.Core
Expand All @@ -11,7 +10,7 @@ public class AnyOfTests
private readonly CustomMatcher<string> _failingMatcher = new CustomMatcher<string>("Failing matcher", s => false);
private readonly CustomMatcher<string> _successfulMatcher = new CustomMatcher<string>("Successful matcher", s => true);
private readonly CustomMatcher<string> _explodingMatcher = new CustomMatcher<string>("Exploding matcher!",
s => { throw new Exception("BANG!!!1!. Didn't expect exploding matcher to run."); });
s => throw new Exception("BANG!!!1!. Didn't expect exploding matcher to run."));

[Fact]
public void Match_if_any_matchers_succeed()
Expand Down
17 changes: 8 additions & 9 deletions src/NHamcrest.Tests/Core/CombinableMatcherTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using NHamcrest.Core;
using Xunit;

Expand Down Expand Up @@ -46,15 +45,15 @@ public void Either_returns_no_match_if_all_fail()
Assert.False(matcher.Matches(""));
}

[Fact]
public void DescribeTo()
{
var matcher = new CombinableMatcher<string>(_failingMatcher);
var description = new StringDescription();
[Fact]
public void DescribeTo()
{
var matcher = new CombinableMatcher<string>(_failingMatcher);
var description = new StringDescription();

matcher.DescribeTo(description);
matcher.DescribeTo(description);

Assert.Equal("Failing matcher", description.ToString());
}
Assert.Equal("Failing matcher", description.ToString());
}
}
}
21 changes: 10 additions & 11 deletions src/NHamcrest.Tests/Core/EveryTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using NHamcrest.Core;
using Xunit;
using Assert = NHamcrest.Tests.Internal.Assert;
Expand All @@ -7,13 +6,13 @@ namespace NHamcrest.Tests.Core
{
public class EveryTests
{
private readonly IMatcher<string> _startsWithA = new CustomMatcher<string>("starts with an A",
private readonly IMatcher<string> _startsWithA = new CustomMatcher<string>("starts with an A",
s => s.StartsWith("A"));

[Fact]
public void Match_if_all_elements_match()
{
var strings = new[] {"Aaaa", "Abbbb", "Acccc"};
var strings = new[] { "Aaaa", "Abbbb", "Acccc" };

Assert.That(strings, Every.Item(_startsWithA));
}
Expand All @@ -26,15 +25,15 @@ public void No_match_if_any_element_does_not_match()
Assert.That(strings, NotEvery.Item(_startsWithA));
}

[Fact]
public void Describe_to()
{
var matcher = Every.Item(_startsWithA);
var description = new StringDescription();
[Fact]
public void Describe_to()
{
var matcher = Every.Item(_startsWithA);
var description = new StringDescription();

matcher.DescribeTo(description);
matcher.DescribeTo(description);

Assert.That(description.ToString(), Is.EqualTo("every item starts with an A"));
}
Assert.That(description.ToString(), Is.EqualTo("every item starts with an A"));
}
}
}
1 change: 0 additions & 1 deletion src/NHamcrest.Tests/Core/IsAnythingTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using NHamcrest.Core;
using Xunit;
using Assert = NHamcrest.Tests.Internal.Assert;
Expand Down
19 changes: 9 additions & 10 deletions src/NHamcrest.Tests/Core/IsCollectionContainingTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using NHamcrest.Core;
using Xunit;
using Assert = NHamcrest.Tests.Internal.Assert;
Expand All @@ -10,7 +9,7 @@ public class IsCollectionContainingTests
[Fact]
public void Has_item()
{
Assert.That(new[] {"aaa", "bbb", "ccc"}, Has.Item(Is.EqualTo("aaa")));
Assert.That(new[] { "aaa", "bbb", "ccc" }, Has.Item(Is.EqualTo("aaa")));
}

[Fact]
Expand All @@ -30,15 +29,15 @@ public void Describe_to_appends_matcher_description()
Assert.That(description.ToString(), Is.EqualTo("a collection containing \"aaa\""));
}

[Fact]
public void Describe_mismatch()
{
var matcher = Has.Item(Is.EqualTo("aaa"));
var description = new StringDescription();
[Fact]
public void Describe_mismatch()
{
var matcher = Has.Item(Is.EqualTo("aaa"));
var description = new StringDescription();

matcher.DescribeMismatch(new [] { "bbb", "ddd" }, description);
matcher.DescribeMismatch(new[] { "bbb", "ddd" }, description);

Assert.That(description.ToString(), Is.EqualTo("was \"bbb\", was \"ddd\""));
}
Assert.That(description.ToString(), Is.EqualTo("was \"bbb\", was \"ddd\""));
}
}
}
65 changes: 32 additions & 33 deletions src/NHamcrest.Tests/Core/IsGreaterThanOrEqualToTests.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@

using NHamcrest.Core;
using Xunit;
using NHAssert = NHamcrest.Tests.Internal.Assert;

namespace NHamcrest.Tests.Core
{
public class IsGreaterThanOrEqualToTests
{
[Fact]
public void Match_if_greater()
{
const int five = 5;
public class IsGreaterThanOrEqualToTests
{
[Fact]
public void Match_if_greater()
{
const int five = 5;

NHAssert.That(five, Is.GreaterThanOrEqualTo(3));
}
NHAssert.That(five, Is.GreaterThanOrEqualTo(3));
}

[Fact]
public void No_match_if_less()
{
var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1);
[Fact]
public void No_match_if_less()
{
var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1);

var matches = isGreaterThanOrEqualToOne.Matches(0);
var matches = isGreaterThanOrEqualToOne.Matches(0);

Assert.False(matches);
}
Assert.False(matches);
}

[Fact]
public void Match_if_equal()
{
var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1);
[Fact]
public void Match_if_equal()
{
var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1);

var matches = isGreaterThanOrEqualToOne.Matches(1);
var matches = isGreaterThanOrEqualToOne.Matches(1);

Assert.True(matches);
}
Assert.True(matches);
}

[Fact]
public void Append_description()
{
const int six = 6;
var greaterThan = Is.GreaterThanOrEqualTo(six);
var description = new StringDescription();
[Fact]
public void Append_description()
{
const int six = 6;
var greaterThan = Is.GreaterThanOrEqualTo(six);
var description = new StringDescription();

greaterThan.DescribeTo(description);
greaterThan.DescribeTo(description);

Assert.Equal(description.ToString(), "greater than or equal to " + six);
}
}
Assert.Equal(description.ToString(), "greater than or equal to " + six);
}
}
}
65 changes: 32 additions & 33 deletions src/NHamcrest.Tests/Core/IsGreaterThanTests.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@

using NHamcrest.Core;
using Xunit;
using NHAssert = NHamcrest.Tests.Internal.Assert;

namespace NHamcrest.Tests.Core
{
public class IsGreaterThanTests
{
[Fact]
public void Match_if_greater()
{
const int five = 5;
public class IsGreaterThanTests
{
[Fact]
public void Match_if_greater()
{
const int five = 5;

NHAssert.That(five, Is.GreaterThan(3));
}
NHAssert.That(five, Is.GreaterThan(3));
}

[Fact]
public void No_match_if_not_greater()
{
var isGreaterThanOne = new IsGreaterThan<int>(1);
[Fact]
public void No_match_if_not_greater()
{
var isGreaterThanOne = new IsGreaterThan<int>(1);

var matches = isGreaterThanOne.Matches(0);
var matches = isGreaterThanOne.Matches(0);

Assert.False(matches);
}
Assert.False(matches);
}

[Fact]
public void No_match_if_equal()
{
var isGreaterThanOne = new IsGreaterThan<int>(1);
[Fact]
public void No_match_if_equal()
{
var isGreaterThanOne = new IsGreaterThan<int>(1);

var matches = isGreaterThanOne.Matches(1);
var matches = isGreaterThanOne.Matches(1);

Assert.False(matches);
}
Assert.False(matches);
}

[Fact]
public void Append_description()
{
const int six = 6;
var greaterThan = Is.GreaterThan(six);
var description = new StringDescription();
[Fact]
public void Append_description()
{
const int six = 6;
var greaterThan = Is.GreaterThan(six);
var description = new StringDescription();

greaterThan.DescribeTo(description);
greaterThan.DescribeTo(description);

Assert.Equal(description.ToString(), "greater than " + six);
}
}
Assert.Equal(description.ToString(), "greater than " + six);
}
}
}
3 changes: 1 addition & 2 deletions src/NHamcrest.Tests/Core/IsInstanceOfTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using NHamcrest.Core;
using Xunit;
using Assert = NHamcrest.Tests.Internal.Assert;
Expand Down Expand Up @@ -53,7 +52,7 @@ public void Describe_mismatch()

matcher.DescribeMismatch(simonChurch, description);

const string errorMessage = "Simon Church is an instance of NHamcrest.Tests.Core.IsInstanceOfTests+SimonChurch not" +
const string errorMessage = "Simon Church is an instance of NHamcrest.Tests.Core.IsInstanceOfTests+SimonChurch not" +
" NHamcrest.Tests.Core.IsInstanceOfTests+ShaneLong";
Assert.That(description.ToString(), Is.EqualTo(errorMessage));
}
Expand Down
Loading