update WireMockServer_Should_delay_responses_for_a_given_route

This commit is contained in:
Stef Heyenrath
2021-12-08 21:56:26 +01:00
parent c6e4608039
commit 3dafd2e725

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Net; using System.Net;
@@ -6,6 +6,7 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using FluentAssertions;
using NFluent; using NFluent;
using WireMock.RequestBuilders; using WireMock.RequestBuilders;
using WireMock.ResponseBuilders; using WireMock.ResponseBuilders;
@@ -93,7 +94,7 @@ namespace WireMock.Net.Tests
[Fact] [Fact]
public async Task WireMockServer_Should_delay_responses_for_a_given_route() public async Task WireMockServer_Should_delay_responses_for_a_given_route()
{ {
// given // Arrange
var server = WireMockServer.Start(); var server = WireMockServer.Start();
server server
@@ -103,14 +104,14 @@ namespace WireMock.Net.Tests
.WithBody(@"{ msg: ""Hello world!""}") .WithBody(@"{ msg: ""Hello world!""}")
.WithDelay(TimeSpan.FromMilliseconds(200))); .WithDelay(TimeSpan.FromMilliseconds(200)));
// when // Act
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/foo"); await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/foo");
watch.Stop(); watch.Stop();
// then // Asser.
Check.That(watch.ElapsedMilliseconds).IsStrictlyGreaterThan(200); watch.ElapsedMilliseconds.Should().BeGreaterOrEqualTo(200);
server.Stop(); server.Stop();
} }