For an intro what this library is solving, check out my blog article.
dotnet add package NSubstituteEquivalency
or
dotnet paket add NSubstituteEquivalency
3.0.0:
- breaking change: made ArgEx.IsCollectionEquivalentTo() generic, introduced ArgEx.IsEnumerableEquivalentTo() and ArgEx.IsArrayEquivalentTo() to support various collection types in arguments
2.0.0
- breaking change: upgraded to FluentAssertions 6.x
1.1.0:
- feature: added ArgEx.IsCollectionEquivalentTo()
1.0.0: initial nuget release
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()
.UseArray(ArgEx.IsArrayEquivalentTo(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)},
}));
or
var service = Substitute.For<ISomeInterface>();
DoSomethingWith(service);
service.Received()
.UseEnumerable(ArgEx.IsEnumerableEquivalentTo(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)},
}));