mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-18 15:10:17 +02:00
Updated Using WireMock in UnitTests (markdown)
@@ -12,11 +12,9 @@ public void StartMockServer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async void Should_respond_to_request()
|
public async Task Should_respond_to_request()
|
||||||
{
|
{
|
||||||
// Assign
|
// Arrange (start WireMock.Net server)
|
||||||
_sut = new SomeComponentDoingHttpCalls();
|
|
||||||
|
|
||||||
_server
|
_server
|
||||||
.Given(Request.Create().WithPath("/foo").UsingGet())
|
.Given(Request.Create().WithPath("/foo").UsingGet())
|
||||||
.RespondWith(
|
.RespondWith(
|
||||||
@@ -25,8 +23,8 @@ public async void Should_respond_to_request()
|
|||||||
.WithBody(@"{ ""msg"": ""Hello world!"" }")
|
.WithBody(@"{ ""msg"": ""Hello world!"" }")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Act
|
// Act (use a HttpClient which connects to the URL where WireMock.Net is running)
|
||||||
var response = _sut.DoSomething();
|
var response = await new HttpClient().PostAsync($"{_server.Urls[0]}/__admin/mappings", stringContent);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(response).IsEqualTo(EXPECTED_RESULT);
|
Check.That(response).IsEqualTo(EXPECTED_RESULT);
|
||||||
|
|||||||
Reference in New Issue
Block a user