mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-24 09:18:27 +02:00
Fixed StatusCode = null or < 0 (#406)
* . * fix tests * responseModel.StatusCode is int statusCodeAsInt && statusCodeAsInt > 0 * < 0
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user