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

This commit is contained in:
Alastair Crabtree authored and Stef Heyenrath committed 2018-03-03 08:38:03 +00:00
1 parent 2b8a58c68c
commit 3f2c139f90
3 files changed
+39

No files matched your search

@@ -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()
{