From a6b541a770e962f79e3050202fc0165959cd6a32 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Wed, 20 Jan 2021 14:09:32 +0100 Subject: [PATCH] Updated Using WireMock in UnitTests (markdown) --- Using-WireMock-in-UnitTests.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Using-WireMock-in-UnitTests.md b/Using-WireMock-in-UnitTests.md index 13349e9..1ef9c67 100644 --- a/Using-WireMock-in-UnitTests.md +++ b/Using-WireMock-in-UnitTests.md @@ -12,11 +12,9 @@ public void StartMockServer() } [Test] -public async void Should_respond_to_request() +public async Task Should_respond_to_request() { - // Assign - _sut = new SomeComponentDoingHttpCalls(); - + // Arrange (start WireMock.Net server) _server .Given(Request.Create().WithPath("/foo").UsingGet()) .RespondWith( @@ -25,8 +23,8 @@ public async void Should_respond_to_request() .WithBody(@"{ ""msg"": ""Hello world!"" }") ); - // Act - var response = _sut.DoSomething(); + // Act (use a HttpClient which connects to the URL where WireMock.Net is running) + var response = await new HttpClient().PostAsync($"{_server.Urls[0]}/__admin/mappings", stringContent); // Assert Check.That(response).IsEqualTo(EXPECTED_RESULT);