dennisdoomen / dennisdoomen/fluentassertions.mockly

[API Proposal]: Add negative assertions (WithoutHeader, WithoutQueryParam, NotContainRequest)

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Motivation

The API is almost entirely positive. At collection level there is `NotContainRequestFor` and `NotContainUnexpectedCalls`, but there is no way to assert the *absence* of a detail on a request that does exist.

That matters for a class of test that is easy to get wrong otherwise: proving a secret was **not** leaked, that a debug flag was **not** forwarded, or that an internal header was stripped before the call went out.

## Proposed API

On `ContainedRequestAssertions`:

```csharp
requests.Should().ContainRequestFor("/api/users")
.WithoutHeader("X-Internal-Token")
.WithoutQueryParam("debug")
.WithoutBodyProperty("password");
```

On `RequestCollectionAssertions`:

```csharp
requests.Should().NotContainRequest(); // counterpart to the existing ContainRequest()
```

## Notes

- `WithoutHeader` is the highest-value one: "we do not forward the caller's `Authorization` header to this downstream service" is a real security assertion that currently has no clean expression.
- Failure messages should show what *was* present, consistent with the rest of the library.
- Additive; needs an `AcceptApiChanges.ps1` run.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the existing ContainedRequestAssertions and RequestCollectionAssertions APIs, especially NotContainRequestFor, NotContainUnexpectedCalls, and ContainRequest. Trace how assertion failure messages report present request details, then assess the proposed WithoutHeader, WithoutQueryParam, WithoutBodyProperty, and NotContainRequest additions. Done means the absence assertions and their failure messages are implemented consistently and AcceptApiChanges.ps1 has been run.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.