Skip to content

ModernRonin/NSubstitute.Equivalency

Repository files navigation

NSubstitute.Equivalency

CI Status NuGet NuGet PRs Welcome

Motivation

For an intro what this library is solving, check out my blog article.

Get it

dotnet add package NSubstituteEquivalency

or

dotnet paket add NSubstituteEquivalency

Release History

2.0.0

  • breaking change: upgraded to FluentAssertions 6.x

1.1.0:

  • feature: added ArgEx.IsCollectionEquivalentTo()

1.0.0: initial nuget release

Use it

var service = Substitute.For<ISomeInterface>();
DoSomethingWith(service);

service.Received()
    .Use(ArgEx.IsEquivalentTo(new Person
    {
        FirstName = "John",
        LastName = "Doe",
        Birthday = new DateTime(1968, 6, 1)
    }));

or

var service = Substitute.For<ISomeInterface>();
DoSomethingWith(service);

service.Received()
    .Use(ArgEx.IsEquivalentTo(new Person
    {
        FirstName = "John",
        LastName = "Doe"
    }, cfg => cfg.Excluding(p => p.Birthday)));

or

var service = Substitute.For<ISomeInterface>();
DoSomethingWith(service);

service.Received()
    .UseCollection(ArgEx.IsCollectionEquivalentTo(new []
    {
        new Person(){FirstName = "Alice", LastName = "Wonderland", Birthday = new DateTime(1968, 6, 1)},
        new Person(){FirstName = "Bob", LastName = "Peanut", Birthday = new DateTime(1972, 9, 13)},
    }));