Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) - #1503
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1503 +/- ##
==========================================
- Coverage 30.76% 30.48% -0.29%
==========================================
Files 163 163
Lines 42251 42626 +375
==========================================
- Hits 12999 12995 -4
- Misses 28889 29270 +381
+ Partials 363 361 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Bafyn This fix is a rather big retfactor... Can you also take a look? |
There was a problem hiding this comment.
Pull request overview
This PR fixes and refactors form-url-encoded body matching by moving form/query parameter values from single strings to WireMockList<string> (to support multi-value keys) and by reworking matcher scoring logic accordingly.
Changes:
- Refactor form-url-encoded parsing and models to represent multiple values per key via
WireMockList<string>. - Rework
FormUrlEncodedMatcherand parameter matching score calculations to better handle multi-value matching scenarios. - Update/extend unit tests to cover single vs multiple values and AND/OR operator behaviors.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/WireMock.Net.Tests/WireMockServerTests.WithBody.cs | Adds a typed FormUrlEncoded body func test using WireMockList<string> values. |
| test/WireMock.Net.Tests/Util/QueryStringParserTests.cs | Updates parser tests for WireMockList<string>-based outputs. |
| test/WireMock.Net.Tests/RequestMatchers/RequestMessageParamMatcherTests.cs | Updates param matcher tests for new scoring behavior and newer collection literals. |
| test/WireMock.Net.Tests/RequestBuilders/RequestBuilderWithBodyTests.cs | Updates request builder test to use WireMockList<string> form-url-encoded bodies. |
| test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs | Major expansion of matcher tests across single/multiple values and AND/OR logic. |
| test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs | Adds equality/operator + Equals/GetHashCode tests for WireMockList<string>. |
| src/WireMock.Net.Shared/Util/QueryStringParser.cs | Changes TryParse to collect multiple values per key into WireMockList<string>. |
| src/WireMock.Net.Shared/RequestBuilders/IBodyRequestBuilder.cs | Breaks API type for form-url-encoded body func to use WireMockList<string>. |
| src/WireMock.Net.Shared/Models/BodyData.cs | Updates BodyAsFormUrlEncoded to IDictionary<string, WireMockList<string>>. |
| src/WireMock.Net.Shared/Matchers/MatchScores.cs | Broadens score helpers to IEnumerable<T> and adds list-vs-matchers scoring helper. |
| src/WireMock.Net.Shared/Extensions/AnyOfExtensions.cs | Minor using cleanup. |
| src/WireMock.Net.Minimal/RequestBuilders/Request.WithBody.cs | Updates WithBody overload signature for form-url-encoded func. |
| src/WireMock.Net.Minimal/Matchers/Request/RequestMessageParamMatcher.cs | Switches param scoring to the new MatchScores.ToScore(list, matchers) logic. |
| src/WireMock.Net.Minimal/Matchers/Request/RequestMessageBodyMatcher.cs | Updates form-url-encoded func signature to use WireMockList<string>. |
| src/WireMock.Net.Minimal/Matchers/FormUrlEncodedMatcher.cs | Reworks internal representation and matching/scoring for multi-value inputs. |
| src/WireMock.Net.Abstractions/Types/WireMockList.cs | Adds operators and value-based equality/hash code implementation. |
| src/WireMock.Net.Abstractions/Models/IBodyData.cs | Updates BodyAsFormUrlEncoded type to WireMockList<string> values. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Bafyn
left a comment
There was a problem hiding this comment.
some comments from copilot also make sense like unused vars, etc.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
No description provided.