feat: add WithBody(req => dostuff) style callback (#102)

This commit is contained in:
Alastair Crabtree
2018-03-03 08:38:03 +00:00
committed by Stef Heyenrath
parent 2b8a58c68c
commit 3f2c139f90
3 changed files with 39 additions and 0 deletions

View File

@@ -232,6 +232,27 @@ namespace WireMock.Net.Tests
Check.That(response).IsEqualTo("Hello world!");
}
[Fact]
public async Task FluentMockServer_Should_respond_to_request_bodyAsCallback()
{
// given
_server = FluentMockServer.Start();
_server
.Given(Request.Create()
.WithPath("/foo")
.UsingGet())
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithBody(req => $"{{ path: '{req.Path}' }}"));
// when
var response = await new HttpClient().GetStringAsync("http://localhost:" + _server.Ports[0] + "/foo");
// then
Check.That(response).IsEqualTo("{ path: '/foo' }");
}
[Fact]
public async Task FluentMockServer_Should_respond_to_request_bodyAsBase64()
{