mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 10:18:26 +02:00
WithCallback should use also use enum HttpStatusCode (#535)
* Fix #533 * simplyfy code
This commit is contained in:
37
test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs
Normal file
37
test/WireMock.Net.Tests/WireMockServerTests.WithCallback.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public partial class WireMockServerTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.Conflict)]
|
||||
[InlineData(409)]
|
||||
[InlineData("409")]
|
||||
public async Task WireMockServer_WithCallback_Should_Use_StatusCodeFromResponse(object statusCode)
|
||||
{
|
||||
// Arrange
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(Request.Create().UsingPost().WithPath("/foo"))
|
||||
.RespondWith(Response.Create()
|
||||
.WithCallback(request => new ResponseMessage
|
||||
{
|
||||
StatusCode = statusCode
|
||||
}));
|
||||
|
||||
// Act
|
||||
using var httpClient = new HttpClient();
|
||||
var response = await httpClient.PostAsync("http://localhost:" + server.Ports[0] + "/foo", new StringContent("dummy"));
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(409);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user