NO ConfigureAwait(false) + cleanup

This commit is contained in:
Stef Heyenrath
2025-08-31 12:39:51 +02:00
parent 0960d7cebd
commit 5b43a4f341
56 changed files with 351 additions and 616 deletions

View File

@@ -37,7 +37,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedNoCalls_AtAbsoluteUrl_WhenACallWasNotMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("xxx").ConfigureAwait(false);
await _httpClient.GetAsync("xxx");
_server.Should()
.HaveReceivedNoCalls()
@@ -47,7 +47,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived0Calls_AtAbsoluteUrl_WhenACallWasNotMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("xxx").ConfigureAwait(false);
await _httpClient.GetAsync("xxx");
_server.Should()
.HaveReceived(0).Calls()
@@ -57,7 +57,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived1Calls_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceived(1).Calls()
@@ -67,7 +67,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived1Calls_AtAbsoluteUrl2_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceived(1).Calls()
@@ -77,7 +77,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived1Calls_AtAbsoluteUrlUsingPost_WhenAPostCallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.PostAsync("anyurl", new StringContent("")).ConfigureAwait(false);
await _httpClient.PostAsync("anyurl", new StringContent(""));
_server.Should()
.HaveReceived(1).Calls()
@@ -89,9 +89,9 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived2Calls_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceived(2).Calls()
@@ -101,7 +101,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceivedACall()
@@ -111,7 +111,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsoluteUrlWildcardMatcher_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceivedACall()
@@ -133,7 +133,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsoluteUrl_Should_ThrowWhenNoCallsMatchingTheAbsoluteUrlWereMade()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -147,7 +147,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedNoCalls_AtAbsolutePath_WhenACallWasNotMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("xxx").ConfigureAwait(false);
await _httpClient.GetAsync("xxx");
_server.Should()
.HaveReceivedNoCalls()
@@ -157,7 +157,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived0Calls_AtAbsolutePath_WhenACallWasNotMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("xxx").ConfigureAwait(false);
await _httpClient.GetAsync("xxx");
_server.Should()
.HaveReceived(0).Calls()
@@ -167,7 +167,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived1Calls_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("anypath").ConfigureAwait(false);
await _httpClient.GetAsync("anypath");
_server.Should()
.HaveReceived(1).Calls()
@@ -177,7 +177,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived1Calls_AtAbsolutePathUsingPost_WhenAPostCallWasMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.PostAsync("anypath", new StringContent("")).ConfigureAwait(false);
await _httpClient.PostAsync("anypath", new StringContent(""));
_server.Should()
.HaveReceived(1).Calls()
@@ -189,9 +189,9 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceived2Calls_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("anypath").ConfigureAwait(false);
await _httpClient.GetAsync("anypath");
await _httpClient.GetAsync("anypath").ConfigureAwait(false);
await _httpClient.GetAsync("anypath");
_server.Should()
.HaveReceived(2).Calls()
@@ -201,7 +201,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("anypath").ConfigureAwait(false);
await _httpClient.GetAsync("anypath");
_server.Should()
.HaveReceivedACall()
@@ -211,7 +211,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsolutePathWildcardMatcher_WhenACallWasMadeToAbsolutePath_Should_BeOK()
{
await _httpClient.GetAsync("anypath").ConfigureAwait(false);
await _httpClient.GetAsync("anypath");
_server.Should()
.HaveReceivedACall()
@@ -233,7 +233,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtAbsolutePath_Should_ThrowWhenNoCallsMatchingTheAbsolutePathWereMade()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -248,7 +248,7 @@ public class WireMockAssertionsTests : IDisposable
public async Task HaveReceivedACall_WithHeader_WhenACallWasMadeWithExpectedHeader_Should_BeOK()
{
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
_server.Should()
.HaveReceivedACall()
@@ -259,7 +259,7 @@ public class WireMockAssertionsTests : IDisposable
public async Task HaveReceivedACall_WithHeader_WhenACallWasMadeWithExpectedHeaderWithValue_Should_BeOK()
{
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
_server.Should()
.HaveReceivedACall()
@@ -271,10 +271,10 @@ public class WireMockAssertionsTests : IDisposable
{
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
await _httpClient.GetAsync("1").ConfigureAwait(false);
await _httpClient.GetAsync("1");
_httpClient.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("EN"));
await _httpClient.GetAsync("2").ConfigureAwait(false);
await _httpClient.GetAsync("2");
_server.Should()
.HaveReceivedACall()
@@ -286,7 +286,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_WithHeader_Should_ThrowWhenNoCallsMatchingTheHeaderNameWereMade()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -302,7 +302,7 @@ public class WireMockAssertionsTests : IDisposable
{
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -320,7 +320,7 @@ public class WireMockAssertionsTests : IDisposable
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
await httpClient.GetAsync("").ConfigureAwait(false);
await httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -374,7 +374,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtUrl_WhenACallWasMadeToUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceivedACall()
@@ -384,7 +384,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtUrlWildcardMatcher_WhenACallWasMadeToUrl_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceivedACall()
@@ -406,7 +406,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_AtUrl_Should_ThrowWhenNoCallsMatchingTheUrlWereMade()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -424,7 +424,7 @@ public class WireMockAssertionsTests : IDisposable
_server.Given(Request.Create().UsingAnyMethod())
.RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" }));
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
_server.Should()
.HaveReceivedACall()
@@ -454,7 +454,7 @@ public class WireMockAssertionsTests : IDisposable
_server.Given(Request.Create().UsingAnyMethod())
.RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" }));
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -468,7 +468,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_FromClientIP_whenACallWasMadeFromClientIP_Should_BeOK()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
var clientIP = _server.LogEntries.Last().RequestMessage.ClientIP;
_server.Should()
@@ -491,7 +491,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_FromClientIP_Should_ThrowWhenNoCallsFromClientIPWereMade()
{
await _httpClient.GetAsync("").ConfigureAwait(false);
await _httpClient.GetAsync("");
var clientIP = _server.LogEntries.Last().RequestMessage.ClientIP;
Action act = () => _server.Should()
@@ -506,7 +506,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedNoCalls_UsingPost_WhenACallWasNotMadeUsingPost_Should_BeOK()
{
await _httpClient.GetAsync("anyurl").ConfigureAwait(false);
await _httpClient.GetAsync("anyurl");
_server.Should()
.HaveReceivedNoCalls()
@@ -545,7 +545,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingOptions_Should_ThrowWhenCallsWereNotMadeUsingOptions()
{
await _httpClient.PostAsync("anyurl", new StringContent("anycontent")).ConfigureAwait(false);
await _httpClient.PostAsync("anyurl", new StringContent("anycontent"));
Action act = () => _server.Should()
.HaveReceivedACall()
@@ -566,7 +566,7 @@ public class WireMockAssertionsTests : IDisposable
_httpClient.DefaultRequestHeaders.Add("Host", new Uri(_server.Urls[0]).Authority);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("CONNECT"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("CONNECT"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -577,7 +577,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingDelete_WhenACallWasMadeUsingDelete_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("DELETE"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("DELETE"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -587,7 +587,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingGet_WhenACallWasMadeUsingGet_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -597,7 +597,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingHead_WhenACallWasMadeUsingHead_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("HEAD"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("HEAD"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -607,7 +607,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingOptions_WhenACallWasMadeUsingOptions_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("OPTIONS"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("OPTIONS"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -619,7 +619,7 @@ public class WireMockAssertionsTests : IDisposable
[InlineData("Post")]
public async Task HaveReceivedACall_UsingPost_WhenACallWasMadeUsingPost_Should_BeOK(string method)
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod(method), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod(method), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -704,7 +704,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingPatch_WhenACallWasMadeUsingPatch_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -714,7 +714,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingPut_WhenACallWasMadeUsingPut_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PUT"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PUT"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -724,7 +724,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingTrace_WhenACallWasMadeUsingTrace_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("TRACE"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("TRACE"), "anyurl"));
_server.Should()
.HaveReceivedACall()
@@ -734,7 +734,7 @@ public class WireMockAssertionsTests : IDisposable
[Fact]
public async Task HaveReceivedACall_UsingAnyMethod_WhenACallWasMadeUsingGet_Should_BeOK()
{
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl")).ConfigureAwait(false);
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"));
_server.Should()
.HaveReceivedACall()