mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-28 11:17:02 +02:00
Updated Using WireMock in UnitTests (markdown)
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user