ronaldbosma / FluentAssertions.ArgumentMatchers.Moq

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:The Unlicense


Languages

Language:C# 100.0%