FluentAssertions - assert the server has not received a call #418

Closed
opened 2025-12-29 15:23:28 +01:00 by adam · 2 comments
Owner

Originally created by @MeuLee on GitHub (May 10, 2022).

Originally assigned to: @StefH on GitHub.

Is your feature request related to a problem? Please describe.
Using HaveReceived(0).Calls() throws an exception if no calls have been made.
"Expected StubServer to have been called at address matching the absolute url "https://localhost:62040/path/to/the/resource", but no calls were made."

Describe the solution you'd like
HaveReceived(0).Calls() should validate that no calls have been made to the stub server, optionally taking into account the specifications such as .AtAbsoluteUrl()
I suppose the method was not intended to be used this way, but I think it would be neat to leverage WireMock.FluentAssertions for this kind of tests.
A use case I have in mind is for caching server responses.

Describe alternatives you've considered
I am currently using the following - just FluentAssertions, not the WireMock version.

StubServer.LogEntries.Should().NotContain(logEntry => logEntry.RequestMessage.Path == "/path/to/the/resource");
Originally created by @MeuLee on GitHub (May 10, 2022). Originally assigned to: @StefH on GitHub. **Is your feature request related to a problem? Please describe.** Using `HaveReceived(0).Calls()` throws an exception if no calls have been made. "Expected StubServer to have been called at address matching the absolute url "https://localhost:62040/path/to/the/resource", but no calls were made." **Describe the solution you'd like** `HaveReceived(0).Calls()` should validate that no calls have been made to the stub server, optionally taking into account the specifications such as `.AtAbsoluteUrl()` I suppose the method was not intended to be used this way, but I think it would be neat to leverage WireMock.FluentAssertions for this kind of tests. A use case I have in mind is for caching server responses. **Describe alternatives you've considered** I am currently using the following - just FluentAssertions, not the WireMock version. ```cs StubServer.LogEntries.Should().NotContain(logEntry => logEntry.RequestMessage.Path == "/path/to/the/resource"); ```
adam added the feature label 2025-12-29 15:23:28 +01:00
adam closed this issue 2025-12-29 15:23:28 +01:00
Author
Owner

@StefH commented on GitHub (May 11, 2022):

@MeuLee
Good point. I'll take a look.

@StefH commented on GitHub (May 11, 2022): @MeuLee Good point. I'll take a look.
Author
Owner

@StefH commented on GitHub (May 13, 2022):

Will be fixed in new version.

@StefH commented on GitHub (May 13, 2022): Will be fixed in new version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#418