mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-22 08:18:26 +02:00
fix (#487)
This commit is contained in:
@@ -87,7 +87,7 @@ namespace WireMock.Serialization
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (methodMatcher?.Methods != null && methodMatcher.Methods.All(m => m != "get") && bodyMatcher?.Matchers != null)
|
if (bodyMatcher?.Matchers != null)
|
||||||
{
|
{
|
||||||
mappingModel.Request.Body = new BodyModel();
|
mappingModel.Request.Body = new BodyModel();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Net.Http;
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
using RestEase;
|
using RestEase;
|
||||||
@@ -95,7 +96,7 @@ namespace WireMock.Net.Tests
|
|||||||
[InlineData(0, 0)]
|
[InlineData(0, 0)]
|
||||||
[InlineData(200, 200)]
|
[InlineData(200, 200)]
|
||||||
[InlineData("200", "200")]
|
[InlineData("200", "200")]
|
||||||
public async Task IWireMockAdminApi_PostMappingAsync(object statusCode, object expectedStatusCode)
|
public async Task IWireMockAdminApi_PostMappingAsync_WithStatusCode(object statusCode, object expectedStatusCode)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var server = WireMockServer.StartWithAdminInterface();
|
var server = WireMockServer.StartWithAdminInterface();
|
||||||
@@ -241,6 +242,49 @@ namespace WireMock.Net.Tests
|
|||||||
Check.That(requestLogged.Request.Body).Contains("T000001");
|
Check.That(requestLogged.Request.Body).Contains("T000001");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IWireMockAdminApi_GetMappingAsync_WithBodyModelMatcherModel_WithoutMethods_ShouldReturnCorrectMappingModel()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var guid = Guid.NewGuid();
|
||||||
|
var server = WireMockServer.StartWithAdminInterface();
|
||||||
|
var api = RestClient.For<IWireMockAdminApi>(server.Urls[0]);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var model = new MappingModel
|
||||||
|
{
|
||||||
|
Guid = guid,
|
||||||
|
Request = new RequestModel
|
||||||
|
{
|
||||||
|
Path = "/1",
|
||||||
|
Body = new BodyModel
|
||||||
|
{
|
||||||
|
Matcher = new MatcherModel
|
||||||
|
{
|
||||||
|
Name = "RegexMatcher",
|
||||||
|
Pattern = "hello",
|
||||||
|
IgnoreCase = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Response = new ResponseModel { Body = "world" }
|
||||||
|
};
|
||||||
|
var postMappingResult = await api.PostMappingAsync(model);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
postMappingResult.Should().NotBeNull();
|
||||||
|
|
||||||
|
var mapping = server.Mappings.FirstOrDefault(m => m.Guid == guid);
|
||||||
|
mapping.Should().NotBeNull();
|
||||||
|
|
||||||
|
var getMappingResult = await api.GetMappingAsync(guid);
|
||||||
|
getMappingResult.Should().NotBeNull();
|
||||||
|
|
||||||
|
getMappingResult.Request.Body.Should().BeEquivalentTo(model.Request.Body);
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task IWireMockAdminApi_GetRequestsAsync_Json()
|
public async Task IWireMockAdminApi_GetRequestsAsync_Json()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user