ModernRonin / NSubstitute.Equivalency

Equivalence based argument matcher for NSubstitute

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)},
    }));

About

Equivalence based argument matcher for NSubstitute

License:Other


Languages

Language:C# 93.4%Language:PowerShell 6.6%