fix comments

This commit is contained in:
Stef Heyenrath
2026-08-19 19:52:48 +02:00
parent 0809c1888f
commit 3d7dbc8544
4 changed files with 14 additions and 15 deletions
@@ -117,7 +117,7 @@ public class FormUrlEncodedMatcher : IStringMatcher, IIgnoreCaseMatcher
var matches = GetMatches(inputNameValueCollection); var matches = GetMatches(inputNameValueCollection);
var score = MatchScores.ToScore(matches, MatchOperator); var score = MatchScores.ToScore(matches, MatchOperator);
return MatchResult.From(Name, score); return MatchResult.From(Name, MatchBehaviourHelper.Convert(MatchBehaviour, score));
} }
private List<double> GetMatches(IDictionary<string, WireMockList<string>> inputNameValueCollection) private List<double> GetMatches(IDictionary<string, WireMockList<string>> inputNameValueCollection)
@@ -55,7 +55,7 @@ public static class MatchScores
/// <param name="values">The values.</param> /// <param name="values">The values.</param>
/// <param name="matchOperator">The <see cref="MatchOperator"/>.</param> /// <param name="matchOperator">The <see cref="MatchOperator"/>.</param>
/// <returns>average score</returns> /// <returns>average score</returns>
public static double ToScore(IEnumerable<bool> values, MatchOperator matchOperator) public static double ToScore(IReadOnlyList<bool> values, MatchOperator matchOperator)
{ {
return ToScore(values.Select(ToScore).ToArray(), matchOperator); return ToScore(values.Select(ToScore).ToArray(), matchOperator);
} }
@@ -66,9 +66,9 @@ public static class MatchScores
/// <param name="values">The values.</param> /// <param name="values">The values.</param>
/// <param name="matchOperator"></param> /// <param name="matchOperator"></param>
/// <returns>average score</returns> /// <returns>average score</returns>
public static double ToScore(IEnumerable<double> values, MatchOperator matchOperator) public static double ToScore(IReadOnlyList<double> values, MatchOperator matchOperator)
{ {
if (!values.Any()) if (values.Count == 0)
{ {
return Mismatch; return Mismatch;
} }
@@ -33,7 +33,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_Single_Or(bool expected, params string[] patterns) public async Task FormUrlEncodedMatcher_IsMatch_Single_Or(bool expected, params string[] patterns)
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com") new KeyValuePair<string, string>("email", "johndoe@example.com")
@@ -72,7 +72,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_Multiple_Or(bool expected, params string[] patterns) public async Task FormUrlEncodedMatcher_IsMatch_Multiple_Or(bool expected, params string[] patterns)
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("name", "Stef"), new KeyValuePair<string, string>("name", "Stef"),
@@ -112,7 +112,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_Single_And(bool expected, params string[] patterns) public async Task FormUrlEncodedMatcher_IsMatch_Single_And(bool expected, params string[] patterns)
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com") new KeyValuePair<string, string>("email", "johndoe@example.com")
@@ -151,7 +151,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_Multiple_And(bool expected, params string[] patterns) public async Task FormUrlEncodedMatcher_IsMatch_Multiple_And(bool expected, params string[] patterns)
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("name", "Stef"), new KeyValuePair<string, string>("name", "Stef"),
@@ -172,7 +172,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties_MissingRequiredKey_ShouldNotMatch() public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties_MissingRequiredKey_ShouldNotMatch()
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("name", "Stef"), new KeyValuePair<string, string>("name", "Stef"),
@@ -194,7 +194,7 @@ public class FormUrlEncodedMatcherTest
public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties_ConflictingEmailPatterns_ShouldNotMatch() public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties_ConflictingEmailPatterns_ShouldNotMatch()
{ {
// Arrange // Arrange
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("name", "Stef"), new KeyValuePair<string, string>("name", "Stef"),
@@ -411,7 +411,7 @@ public partial class WireMockServerTests
); );
// Act // Act
var content = new FormUrlEncodedContent( using var content = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com") new KeyValuePair<string, string>("email", "johndoe@example.com")
@@ -429,7 +429,7 @@ public partial class WireMockServerTests
public async Task WireMockServer_WithBodyAsFormUrlEncoded_Using_PostAsync_And_WithFormUrlEncodedMatcher() public async Task WireMockServer_WithBodyAsFormUrlEncoded_Using_PostAsync_And_WithFormUrlEncodedMatcher()
{ {
// Arrange // Arrange
var matcher = new FormUrlEncodedMatcher(["email=johndoe@example.com", "name=John Doe"]); var matcher = new FormUrlEncodedMatcher(["email=johndoe@example.com", "name=John*"]);
using var server = WireMockServer.Start(); using var server = WireMockServer.Start();
server.Given( server.Given(
Request.Create() Request.Create()
@@ -454,7 +454,7 @@ public partial class WireMockServerTests
); );
// Act 1 // Act 1
var contentOrdered = new FormUrlEncodedContent( using var contentOrdered = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
new KeyValuePair<string, string>("email", "johndoe@example.com") new KeyValuePair<string, string>("email", "johndoe@example.com")
@@ -468,7 +468,7 @@ public partial class WireMockServerTests
// Act 2 // Act 2
var contentUnordered = new FormUrlEncodedContent( using var contentUnordered = new FormUrlEncodedContent(
[ [
new KeyValuePair<string, string>("email", "johndoe@example.com"), new KeyValuePair<string, string>("email", "johndoe@example.com"),
new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("name", "John Doe"),
@@ -476,7 +476,6 @@ public partial class WireMockServerTests
var responseUnordered = await new HttpClient() var responseUnordered = await new HttpClient()
.PostAsync($"{server.Url}/bar", contentUnordered, _ct) .PostAsync($"{server.Url}/bar", contentUnordered, _ct)
; ;
// Assert 2 // Assert 2
responseUnordered.StatusCode.Should().Be(HttpStatusCode.OK); responseUnordered.StatusCode.Should().Be(HttpStatusCode.OK);