Updated Using WireMock in UnitTests (markdown)

Stef Heyenrath
2017-11-23 07:52:07 +01:00
parent b213c5fba3
commit cacfd4e1e8

@@ -4,7 +4,7 @@ Obviously you can use your favourite test framework and use WireMock within your
- clean up the request log or shutdown the server at the end of each test - clean up the request log or shutdown the server at the end of each test
Below a simple example using Nunit and NFluent test assertion library: Below a simple example using Nunit and NFluent test assertion library:
```csharp ```cs
[SetUp] [SetUp]
public void StartMockServer() public void StartMockServer()
{ {
@@ -18,7 +18,7 @@ public async void Should_respond_to_request()
_sut = new SomeComponentDoingHttpCalls(); _sut = new SomeComponentDoingHttpCalls();
_server _server
.Given(Request.Create().WithUrl("/foo").UsingGet()) .Given(Request.Create().WithPath("/foo").UsingGet())
.RespondWith( .RespondWith(
Response.Create() Response.Create()
.WithStatusCode(200) .WithStatusCode(200)
@@ -30,9 +30,6 @@ public async void Should_respond_to_request()
// then // then
Check.That(response).IsEqualTo(EXPECTED_RESULT); Check.That(response).IsEqualTo(EXPECTED_RESULT);
// and optionally
Check.That(_server.FindLogEntries(Request.WithUrl("/error*")).IsEmpty();
} }
[TearDown] [TearDown]