mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:43:48 +01:00
Fix RequestMessageParamMatcher : RejectOnMatch (#1006)
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
@@ -26,10 +27,10 @@ public partial class WireMockServerTests
|
||||
};
|
||||
var server = WireMockServer.Start(settings);
|
||||
server.Given(
|
||||
Request.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/foo")
|
||||
.WithParam("query", queryValue)
|
||||
Request.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/foo")
|
||||
.WithParam("query", queryValue)
|
||||
)
|
||||
.RespondWith(
|
||||
Response.Create().WithStatusCode(200)
|
||||
@@ -52,10 +53,10 @@ public partial class WireMockServerTests
|
||||
var queryValue = "1,2,3";
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(
|
||||
Request.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/foo")
|
||||
.WithParam("query", "1", "2", "3")
|
||||
Request.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/foo")
|
||||
.WithParam("query", "1", "2", "3")
|
||||
)
|
||||
.RespondWith(
|
||||
Response.Create().WithStatusCode(200)
|
||||
@@ -70,4 +71,54 @@ public partial class WireMockServerTests
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithParam_RejectOnMatch_OnNonMatchingParam_ShouldReturnMappingOk()
|
||||
{
|
||||
// Arrange
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(
|
||||
Request.Create()
|
||||
.WithPath("/v1/person/workers")
|
||||
.WithParam("delta_from", MatchBehaviour.RejectOnMatch)
|
||||
.UsingGet()
|
||||
)
|
||||
.RespondWith(
|
||||
Response.Create()
|
||||
);
|
||||
|
||||
// Act
|
||||
var requestUri = new Uri($"http://localhost:{server.Port}/v1/person/workers?showsourcesystem=true&count=700&page=1§ions=personal%2Corganizations%2Cemployment");
|
||||
var response = await server.CreateClient().GetAsync(requestUri).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithParam_AcceptOnMatch_OnNonMatchingParam_ShouldReturnMappingOk()
|
||||
{
|
||||
// Arrange
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(
|
||||
Request.Create()
|
||||
.WithPath("/v1/person/workers")
|
||||
.WithParam("delta_from")
|
||||
.UsingGet()
|
||||
)
|
||||
.RespondWith(
|
||||
Response.Create()
|
||||
);
|
||||
|
||||
// Act
|
||||
var requestUri = new Uri($"http://localhost:{server.Port}/v1/person/workers?showsourcesystem=true&count=700&page=1§ions=personal%2Corganizations%2Cemployment");
|
||||
var response = await server.CreateClient().GetAsync(requestUri).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user