https://github.com/ronaldbosma/fluentassertions.argumentmatchers.fakeiteasy
The FluentAssertions.ArgumentMatchers.FakeItEasy package provides a simple way to use FakeItEasy in combination with FluentAssertions to compare complex objects.
https://github.com/ronaldbosma/fluentassertions.argumentmatchers.fakeiteasy
fakeiteasy fluentassertions
Last synced: 3 months ago
JSON representation
The FluentAssertions.ArgumentMatchers.FakeItEasy package provides a simple way to use FakeItEasy in combination with FluentAssertions to compare complex objects.
- Host: GitHub
- URL: https://github.com/ronaldbosma/fluentassertions.argumentmatchers.fakeiteasy
- Owner: ronaldbosma
- License: unlicense
- Created: 2021-04-12T17:19:13.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-07T11:26:48.000Z (5 months ago)
- Last Synced: 2025-01-23T18:15:22.764Z (3 months ago)
- Topics: fakeiteasy, fluentassertions
- Language: C#
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

FluentAssertions.ArgumentMatchers.FakeItEasy
===The [FluentAssertions.ArgumentMatchers.FakeItEasy NuGet package](https://www.nuget.org/packages/FluentAssertions.ArgumentMatchers.FakeItEasy/) provides a simple way to use FakeItEasy in combination with FluentAssertions to compare complex objects.
### IsEquivalentTo
The package has an extension method called `IsEquivalentTo` for `IArgumentConstraintManager`. It can be used in the setup and verify stages of a Fake similar to other argument matchers like `A.Ignored`. 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
```csharp
A.CallTo(() => _fake.DoSomething(A.That.IsEquivalentTo(expectedComplexType))).Returns(result);A.CallTo(() => _fake.DoSomething(A.That.IsEquivalentTo(expectedComplexType))).MustHaveHappenedOnceExactly();
A.CallTo(() => _fake.DoSomething(A.That.IsEquivalentTo(
expectedComplexType,
options => options.Excluding(c => c.SomeProperty)
))).MustHaveHappenedOnceExactly();
```### IsEnumerableEquivalentTo
When comparing collections and certain properties need to be ignored, the `IsEnumerableEquivalentTo` method can be used. The code `actual.Should().BeAssignableTo>().Which.Should().BeEquivalentTo(expected, config)` is used inside to compare the collections. It's important to note that you need to explicitly use `IEnumerable` in `A>.That.IsEnumerableEquivalentTo` for it to work.
#### Examples
```csharp
// Ignore the 'ComplexTypeProperty.IntProperty' property of the ComplexType objects in the collection
A.CallTo(() => _fake.DoSomethingWithCollection(A>.That.IsEnumerableEquivalentTo(
expectedList,
options => options.Excluding(c => c.ComplexTypeProperty.IntProperty)
))).MustHaveHappenedOnceExactly();
```