mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 14:23:34 +01:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
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
|
|
var httpClient = new HttpClient();
|
|
var response = await httpClient.PostAsync("http://localhost:" + server.Ports[0] + "/foo", new StringContent("dummy")).ConfigureAwait(false);
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.Conflict);
|
|
|
|
server.Stop();
|
|
}
|
|
}
|
|
} |