dennisdoomen / dennisdoomen/fluentassertions.mockly
[API Proposal]: Add an equivalency-options overload to WithBodyEquivalentTo
- Dominant language
- C#
- Stars
- 0
- Forks
- 0
- Avg merge
- 11d 7h
- Merged PRs (30d)
- 4
Description
## Motivation
`WithBodyEquivalentTo(T expected, ...)` runs a full equivalency comparison with no way to configure it. That breaks down as soon as the request body contains anything non-deterministic:
- a client-generated `Guid` or correlation id
- a `DateTime` stamped at send time
- a field you simply do not care about
FluentAssertions users expect `BeEquivalentTo` to take an options lambda, and its absence here forces people to abandon the assertion and fall back to `WithBodyHavingProperty` one field at a time — which loses the nice diff output.
## Proposed API
```csharp
requests.Should().ContainRequestFor("/api/users")
.WithBodyEquivalentTo(expected, options => options
.Excluding(x => x.Id)
.Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))
.WhenTypeIs());
```
Signature mirroring FluentAssertions:
```csharp
AndWhichConstraint WithBodyEquivalentTo(
T expected,
Func, EquivalencyOptions> config,
string because = "",
params object[] becauseArgs);
```
## Notes
- The options type differs between FluentAssertions 7 and 8 (`EquivalencyAssertionOptions` vs `EquivalencyOptions`), so this needs the existing `#if FA8` treatment in `Shared/HttpMockAssertionExtensions.cs`.
- The existing parameterless overload stays, delegating with a no-op config.
- Same consideration would apply to a response-side `WithResponseBodyEquivalentTo` if #75 is implemented.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Shared/HttpMockAssertionExtensions.cs and the existing WithBodyEquivalentTo entry point. Check the current #if FA8 treatment and the FluentAssertions option types for versions 7 and 8. Done means the new options overload supports the proposed configuration, the parameterless overload still works through a no-op configuration, and both compatibility paths build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100