Skip to content

Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) - #1503

Merged
StefH merged 4 commits into
masterfrom
formurl_match
Aug 20, 2026
Merged

Fix FormUrlEncodedMatcher (+ refactor values / matchers logic)#1503
StefH merged 4 commits into
masterfrom
formurl_match

Conversation

@StefH

@StefH StefH commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@StefH StefH self-assigned this Aug 19, 2026
@StefH
StefH requested a lite review from Copilot August 19, 2026 05:55
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.15190% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.48%. Comparing base (42353f0) to head (3d7dbc8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...Mock.Net.Minimal/Matchers/FormUrlEncodedMatcher.cs 72.97% 10 Missing ⚠️
src/WireMock.Net.Shared/Matchers/MatchScores.cs 68.00% 8 Missing ⚠️
...ck.Net.Minimal/RequestBuilders/Request.WithBody.cs 0.00% 2 Missing ⚠️
src/WireMock.Net.Shared/Util/QueryStringParser.cs 84.61% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StefH

StefH commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@Bafyn This fix is a rather big retfactor...

Can you also take a look?

Comment thread test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs Dismissed
Comment thread test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs Dismissed
Comment thread test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs Dismissed
Comment thread test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs Fixed
Comment thread test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs Fixed
Comment thread test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs Fixed
Comment thread test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs Fixed
Comment thread test/WireMock.Net.Tests/WireMockServerTests.WithBody.cs Fixed
Comment thread test/WireMock.Net.Tests/WireMockServerTests.WithBody.cs Fixed
Comment thread test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FormUrlEncodedMatcher and 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.

Comment thread src/WireMock.Net.Minimal/Matchers/FormUrlEncodedMatcher.cs
Comment thread src/WireMock.Net.Shared/Matchers/MatchScores.cs Outdated
Comment thread test/WireMock.Net.Tests/WireMockServerTests.WithBody.cs Outdated
Comment thread src/WireMock.Net.Shared/Matchers/MatchScores.cs
Comment thread src/WireMock.Net.Shared/RequestBuilders/IBodyRequestBuilder.cs
Comment thread test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs Outdated
Comment thread test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs Outdated

@Bafyn Bafyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments from copilot also make sense like unused vars, etc.

Comment thread src/WireMock.Net.Minimal/Matchers/FormUrlEncodedMatcher.cs
Comment thread src/WireMock.Net.Shared/Matchers/MatchScores.cs Outdated
Comment thread src/WireMock.Net.Shared/Matchers/MatchScores.cs
StefH and others added 2 commits August 19, 2026 19:15
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>
@StefH StefH changed the title Fix FormurlMatcher logic (+ refactor values / matchers logic) Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) Aug 19, 2026
@StefH
StefH merged commit ee0f890 into master Aug 20, 2026
13 of 15 checks passed
@StefH
StefH deleted the formurl_match branch August 20, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants