FormUrlEncodedMatcher is not requiring to match all properties when MatchOperator.And #626

Closed
opened 2025-12-29 15:29:17 +01:00 by adam · 2 comments
Owner

Originally created by @luheorga on GitHub (Aug 14, 2024).

Originally assigned to: @StefH on GitHub.

Hi, I'm using the FormUrlEncodedMatcher and realized that it is not requiring all the patterns configured to match when MatchOperator.And

Expected behavior:

When FormUrlEncodedMatcher is configured with MatchOperator.And should match all the patterns configured

Test to reproduce

[Fact]
public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties()
{
    // Arrange
    var content = new FormUrlEncodedContent(new[]
    {
        new KeyValuePair<string, string>("name", "John Doe"),
        new KeyValuePair<string, string>("email", "johndoe@example.com")
    });
    var contentAsString = await content.ReadAsStringAsync();

    // The expectation is that the matcher requires all properties to be present in the content.
    var matcher = new FormUrlEncodedMatcher(["name=*", "email=*", "required=*"], matchOperator: MatchOperator.And);

    // Act
    var score = matcher.IsMatch(contentAsString).IsPerfect();

    // Assert
    score.Should().BeFalse();
}
Originally created by @luheorga on GitHub (Aug 14, 2024). Originally assigned to: @StefH on GitHub. Hi, I'm using the `FormUrlEncodedMatcher` and realized that it is not requiring all the patterns configured to match when `MatchOperator.And` ### Expected behavior: When `FormUrlEncodedMatcher` is configured with `MatchOperator.And` should match all the patterns configured ### Test to reproduce ```csharp [Fact] public async Task FormUrlEncodedMatcher_IsMatch_And_MatchAllProperties() { // Arrange var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("name", "John Doe"), new KeyValuePair<string, string>("email", "johndoe@example.com") }); var contentAsString = await content.ReadAsStringAsync(); // The expectation is that the matcher requires all properties to be present in the content. var matcher = new FormUrlEncodedMatcher(["name=*", "email=*", "required=*"], matchOperator: MatchOperator.And); // Act var score = matcher.IsMatch(contentAsString).IsPerfect(); // Assert score.Should().BeFalse(); } ```
adam added the bug label 2025-12-29 15:29:17 +01:00
adam closed this issue 2025-12-29 15:29:17 +01:00
Author
Owner

@StefH commented on GitHub (Aug 15, 2024):

https://github.com/WireMock-Net/WireMock.Net/pull/1157

@StefH commented on GitHub (Aug 15, 2024): https://github.com/WireMock-Net/WireMock.Net/pull/1157
Author
Owner

@luheorga commented on GitHub (Aug 15, 2024):

Hi @StefH, thank you for the celerity on this

@luheorga commented on GitHub (Aug 15, 2024): Hi @StefH, thank you for the celerity on this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#626