BodyAsJsonIndented (#113)

This commit is contained in:
Stef Heyenrath
2018-03-28 09:51:01 +02:00
parent bdb79aec95
commit df4a1f628a
10 changed files with 107 additions and 40 deletions

View File

@@ -232,6 +232,40 @@ namespace WireMock.Net.Tests
Check.That(response).IsEqualTo("Hello world!");
}
[Fact]
public async Task FluentMockServer_Should_respond_to_request_BodyAsJson()
{
// Assign
_server = FluentMockServer.Start();
_server
.Given(Request.Create().UsingAnyVerb())
.RespondWith(Response.Create().WithBodyAsJson(new { message = "Hello" }));
// Act
var response = await new HttpClient().GetStringAsync("http://localhost:" + _server.Ports[0]);
// Assert
Check.That(response).IsEqualTo("{\"message\":\"Hello\"}");
}
[Fact]
public async Task FluentMockServer_Should_respond_to_request_BodyAsJson_Indented()
{
// Assign
_server = FluentMockServer.Start();
_server
.Given(Request.Create().UsingAnyVerb())
.RespondWith(Response.Create().WithBodyAsJson(new { message = "Hello" }, true));
// Act
var response = await new HttpClient().GetStringAsync("http://localhost:" + _server.Ports[0]);
// Assert
Check.That(response).IsEqualTo("{\r\n \"message\": \"Hello\"\r\n}");
}
[Fact]
public async Task FluentMockServer_Should_respond_to_request_bodyAsCallback()
{