Skip to content

The FluentAssertions.ArgumentMatchers.Moq package provides a simple way to use Moq in combination with FluentAssertions to compare complex objects.

License

Notifications You must be signed in to change notification settings

ronaldbosma/FluentAssertions.ArgumentMatchers.Moq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuget

FluentAssertions.ArgumentMatchers.Moq

The FluentAssertions.ArgumentMatchers.Moq NuGet package provides a simple way to use Moq in combination with FluentAssertions to compare complex objects.

The package has a method called Its.EquivalentTo. It can be used in the Setup and Verify stages of a Mock similar to other argument matchers like It.IsAny<T>(). The actual.Should().BeEquivalentTo(expected) method is used inside to compare objects. An overload is available so you can pass in configuration to FluentAssertions.

Examples

_mock.Setup(m => m.DoSomething(Its.EquivalentTo(expectedComplexType))).Returns(result);

_mock.Verify(m => m.DoSomething(Its.EquivalentTo(expectedComplexType)));

_mock.Verify(m => m.DoSomething(Its.EquivalentTo(
    expectedComplexType, 
    options => options.Excluding(c => c.SomeProperty)
)));

About

The FluentAssertions.ArgumentMatchers.Moq package provides a simple way to use Moq in combination with FluentAssertions to compare complex objects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages