Fixed StatusCode = null or < 0 (#406)

* .

* fix tests

* responseModel.StatusCode is int statusCodeAsInt && statusCodeAsInt > 0

* < 0
This commit is contained in:
Stef Heyenrath
2020-01-25 17:51:38 +01:00
committed by GitHub
parent dfbfa5fd35
commit 710fc8dcf6
5 changed files with 69 additions and 10 deletions

View File

@@ -12,6 +12,8 @@ using WireMock.Admin.Settings;
using WireMock.Client;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Models;
using WireMock.Server;
using WireMock.Settings;
using Xunit;
@@ -88,8 +90,13 @@ namespace WireMock.Net.Tests
server.Stop();
}
[Fact]
public async Task IWireMockAdminApi_PostMappingAsync()
[Theory]
[InlineData(null, 200)]
[InlineData(-1, 200)]
[InlineData(0, 200)]
[InlineData(200, 200)]
[InlineData("200", "200")]
public async Task IWireMockAdminApi_PostMappingAsync(object statusCode, object expectedStatusCode)
{
// Arrange
var server = WireMockServer.StartWithAdminInterface();
@@ -99,7 +106,7 @@ namespace WireMock.Net.Tests
var model = new MappingModel
{
Request = new RequestModel { Path = "/1" },
Response = new ResponseModel { Body = "txt", StatusCode = 200 },
Response = new ResponseModel { Body = "txt", StatusCode = statusCode },
Priority = 500,
Title = "test"
};
@@ -114,6 +121,9 @@ namespace WireMock.Net.Tests
Check.That(mapping).IsNotNull();
Check.That(mapping.Title).Equals("test");
var response = await mapping.ProvideResponseAsync(new RequestMessage(new UrlDetails("http://localhost/1"), "GET", ""));
Check.That(response.StatusCode).Equals(expectedStatusCode);
server.Stop();
}