feat: make HttpContent parameter optional#454
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the HttpClient mocking API by making the HttpContent parameter optional in setup and verification methods for POST, PUT, and PATCH operations. It also removes nullability from non-optional parameters across HTTP methods to improve type safety.
Changes:
- Made
contentparameter optional with default valuenullfor POST/PUT/PATCH operations - Removed nullability (
?) fromrequestUriandcontentparameters in overloads that acceptCancellationToken - Updated internal parameter handling to use null-coalescing operator with
It.IsAny<T>()for optional parameters - Added tests to verify
HttpContentparameter matching behavior
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Mockolate.Internal.Tests/WebTests.cs | Added tests for HttpContent parameter matching edge cases |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_*.txt | Updated API surface snapshots to reflect the new optional parameter signatures |
| Source/Mockolate/Web/HttpClientExtensions.cs | Simplified internal parameter handling by removing nullable logic |
| Source/Mockolate/Web/HttpClientExtensions.Setup.*.cs | Made content parameter optional and updated parameter nullability in Setup methods |
| Source/Mockolate/Web/HttpClientExtensions.Verify.*.cs | Made content parameter optional and updated parameter nullability in Verify methods |
🚀 Benchmark ResultsDetails
|
16393dc to
e4f0e18
Compare
|
|
This is addressed in release v1.2.0. |



This PR enhances the
HttpClientmocking API by making theHttpContentparameter optional in setup and verification methods for POST, PUT, and PATCH operations. It also removes nullability from non-optional parameters across HTTP methods to improve type safety.Key Changes:
contentparameter optional with default valuenullfor POST/PUT/PATCH operations?) fromrequestUriandcontentparameters in overloads that acceptCancellationTokenIt.IsAny<T>()for optional parametersHttpContentparameter matching behavior