WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Version 1.5.33 always returns StatusCode 500 ' Internal Server Error'.
Expected behaviour:
Should return the StatusCode provided in the ResponseBuilder.
Test to reproduce
using System.Net;
using System.Text;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
public class SomeApiClientTests
{
[Fact]
public async Task Should_ReturnCreated_When_PostRequestedIsValid()
{
// Arrange
var server = WireMockServer.Start();
server.Given(Request.Create().UsingPost().WithPath("/some/endpoint"))
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created));
var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) };
var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint");
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
// Act
var actual = await httpClient.PostAsync(requestUri, content);
// Assert
actual.StatusCode.Should().Be(HttpStatusCode.Created);
}
}
Other related info
Ran under .Net 7 with Microsoft Visual Studio Community 2022 (64-bit) -Version 17.6.5
Describe the bug
Version 1.5.33 always returns StatusCode 500 ' Internal Server Error'.
Expected behaviour:
Should return the StatusCode provided in the ResponseBuilder.
Test to reproduce
Other related info
Ran under .Net 7 with Microsoft Visual Studio Community 2022 (64-bit) -Version 17.6.5