mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 08:39:00 +01:00
fix (#487)
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NFluent;
|
||||
using RestEase;
|
||||
@@ -95,7 +96,7 @@ namespace WireMock.Net.Tests
|
||||
[InlineData(0, 0)]
|
||||
[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
|
||||
var server = WireMockServer.StartWithAdminInterface();
|
||||
@@ -241,6 +242,49 @@ namespace WireMock.Net.Tests
|
||||
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]
|
||||
public async Task IWireMockAdminApi_GetRequestsAsync_Json()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user