feat!: add support for URL-encoded form data content#462
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new It.IsFormDataContent() matcher to allow mocking/verifying HTTP calls based on URL-encoded form data (including form data embedded inside multipart form content).
Changes:
- Introduces
It.IsFormDataContent()andIFormDataContentParameterfluent API for matching form data content. - Adds parsing/matching logic for URL-encoded key/value pairs (including URL decoding).
- Adds unit tests covering
.Containing(...)matching behavior and order independence.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| Tests/Mockolate.Tests/Web/ItExtensionsTests.IsFormDataContentTests.cs | Adds tests for the new form-data matcher behavior. |
| Source/Mockolate/Web/ItExtensions.cs | Adds FormDataMatcher helper to extract and match URL-encoded form data. |
| Source/Mockolate/Web/ItExtensions.HttpContent.IsFormDataContent.cs | Adds the public matcher API and hooks it into HttpContent matching. |
| Source/Mockolate/Web/HttpFormDataValue.cs | Introduces a value wrapper for form-data matching with extensible match semantics. |
🚀 Benchmark ResultsDetails
|
59e83b1 to
4496dfa
Compare
…t.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Test Results 21 files ± 0 21 suites ±0 4m 52s ⏱️ -48s Results for commit d089b0f. ± Comparison against base commit 2ae9bf8. This pull request removes 108 and adds 128 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
3140b1d to
e9064e1
Compare
|
|
This is addressed in release v1.3.0. |



This pull request refactors and simplifies the HTTP content parameter matching APIs in the
Mockolate.Webnamespace. It removes specialized interfaces and classes for string and binary content, consolidates their functionality into a more generalIHttpContentParameterinterface, and introduces support for form data content. The changes improve API consistency and extensibility for matching HTTP request content in tests.API Refactoring and Simplification:
Removed the specialized
IsBinaryContentandIsStringContentextension methods, interfaces, and implementations, consolidating their functionality into the new, unifiedIHttpContentParameterinterface. This includes removingIBinaryContentParameter,IStringContentParameter, and related code, and updating the API surface accordingly.Updated the
IHttpRequestMessageParameterinterface and its implementation to removeWhoseStringContentIsandWhoseBinaryContentIsmethods, replacing them with a more flexibleWhoseContentIsmethod that optionally takes a media type and configuration action.New Features:
HttpFormDataValueclass and related API methods, such asWithFormData, to theIHttpContentParameterinterface.Other Improvements:
HttpQueryParameterValue.Matchesto useStringComparison.Ordinalfor consistency and correctness.HttpRequestMessageParameterfor clarity.Test and Documentation Updates:
Mockolate_net10.0.txtto reflect the new interface structure and removed/added methods and classes.These changes make the HTTP content matching API easier to use and extend, while reducing duplication and improving maintainability.