mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-22 08:18:26 +02:00
ct
This commit is contained in:
@@ -16,6 +16,8 @@ namespace WireMock.Net.Tests.FluentAssertions;
|
||||
|
||||
public class WireMockAssertionsTests : IDisposable
|
||||
{
|
||||
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
|
||||
|
||||
private readonly WireMockServer _server;
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly int _portUsed;
|
||||
@@ -26,14 +28,13 @@ public class WireMockAssertionsTests : IDisposable
|
||||
_server.Given(Request.Create().UsingAnyMethod()).RespondWith(Response.Create().WithSuccess());
|
||||
|
||||
_portUsed = _server.Ports.First();
|
||||
|
||||
_httpClient = new HttpClient { BaseAddress = new Uri(_server.Url!) };
|
||||
_httpClient = _server.CreateClient();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HaveReceivedNoCalls_AtAbsoluteUrl_WhenACallWasNotMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("xxx", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("xxx", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedNoCalls()
|
||||
@@ -43,7 +44,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived0Calls_AtAbsoluteUrl_WhenACallWasNotMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("xxx", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("xxx", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(0).Calls()
|
||||
@@ -53,7 +54,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived1Calls_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(1).Calls()
|
||||
@@ -63,7 +64,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived1Calls_AtAbsoluteUrl2_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(1).Calls()
|
||||
@@ -73,7 +74,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived1Calls_AtAbsoluteUrlUsingPost_WhenAPostCallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.PostAsync("anyurl", new StringContent(""), TestContext.Current.CancellationToken);
|
||||
await _httpClient.PostAsync("anyurl", new StringContent(""), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(1).Calls()
|
||||
@@ -85,9 +86,9 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived2Calls_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(2).Calls()
|
||||
@@ -97,7 +98,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsoluteUrl_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -107,7 +108,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsoluteUrlWildcardMatcher_WhenACallWasMadeToAbsoluteUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -129,7 +130,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsoluteUrl_Should_ThrowWhenNoCallsMatchingTheAbsoluteUrlWereMade()
|
||||
{
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -143,7 +144,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedNoCalls_AtAbsolutePath_WhenACallWasNotMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("xxx", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("xxx", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedNoCalls()
|
||||
@@ -153,7 +154,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived0Calls_AtAbsolutePath_WhenACallWasNotMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("xxx", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("xxx", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(0).Calls()
|
||||
@@ -163,7 +164,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived1Calls_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anypath", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anypath", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(1).Calls()
|
||||
@@ -173,7 +174,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived1Calls_AtAbsolutePathUsingPost_WhenAPostCallWasMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.PostAsync("anypath", new StringContent(""), TestContext.Current.CancellationToken);
|
||||
await _httpClient.PostAsync("anypath", new StringContent(""), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(1).Calls()
|
||||
@@ -185,9 +186,9 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceived2Calls_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anypath", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anypath", _ct);
|
||||
|
||||
await _httpClient.GetAsync("anypath", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anypath", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceived(2).Calls()
|
||||
@@ -197,7 +198,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsolutePath_WhenACallWasMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anypath", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anypath", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -207,7 +208,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsolutePathWildcardMatcher_WhenACallWasMadeToAbsolutePath_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anypath", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("anypath", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -229,7 +230,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtAbsolutePath_Should_ThrowWhenNoCallsMatchingTheAbsolutePathWereMade()
|
||||
{
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -244,7 +245,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
public async Task HaveReceivedACall_WithHeader_WhenACallWasMadeWithExpectedHeader_Should_BeOK()
|
||||
{
|
||||
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -255,7 +256,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
public async Task HaveReceivedACall_WithHeader_WhenACallWasMadeWithExpectedHeaderWithValue_Should_BeOK()
|
||||
{
|
||||
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -267,10 +268,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", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("1", _ct);
|
||||
|
||||
_httpClient.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("EN"));
|
||||
await _httpClient.GetAsync("2", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("2", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -282,7 +283,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_WithHeader_Should_ThrowWhenNoCallsMatchingTheHeaderNameWereMade()
|
||||
{
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -298,7 +299,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
{
|
||||
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
|
||||
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
await _httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -316,7 +317,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
await httpClient.GetAsync("", TestContext.Current.CancellationToken);
|
||||
await httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -331,7 +332,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
public async Task HaveReceivedACall_WithHeader_ShouldCheckAllRequests()
|
||||
{
|
||||
// Arrange
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
var cancellationToken = _ct;
|
||||
using var server = WireMockServer.Start();
|
||||
using var client1 = server.CreateClient();
|
||||
|
||||
@@ -371,7 +372,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtUrl_WhenACallWasMadeToUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl");
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -381,7 +382,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtUrlWildcardMatcher_WhenACallWasMadeToUrl_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl");
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -403,7 +404,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_AtUrl_Should_ThrowWhenNoCallsMatchingTheUrlWereMade()
|
||||
{
|
||||
await _httpClient.GetAsync("");
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -421,7 +422,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
_server.Given(Request.Create().UsingAnyMethod())
|
||||
.RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" }));
|
||||
|
||||
await _httpClient.GetAsync("");
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -451,7 +452,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
_server.Given(Request.Create().UsingAnyMethod())
|
||||
.RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999" }));
|
||||
|
||||
await _httpClient.GetAsync("");
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -465,7 +466,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_FromClientIP_whenACallWasMadeFromClientIP_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("");
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
var clientIP = _server.LogEntries.Last().RequestMessage.ClientIP;
|
||||
|
||||
_server.Should()
|
||||
@@ -488,7 +489,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_FromClientIP_Should_ThrowWhenNoCallsFromClientIPWereMade()
|
||||
{
|
||||
await _httpClient.GetAsync("");
|
||||
await _httpClient.GetAsync("", _ct);
|
||||
var clientIP = _server.LogEntries.Last().RequestMessage.ClientIP;
|
||||
|
||||
Action act = () => _server.Should()
|
||||
@@ -503,7 +504,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedNoCalls_UsingPost_WhenACallWasNotMadeUsingPost_Should_BeOK()
|
||||
{
|
||||
await _httpClient.GetAsync("anyurl");
|
||||
await _httpClient.GetAsync("anyurl", _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedNoCalls()
|
||||
@@ -515,9 +516,9 @@ public class WireMockAssertionsTests : IDisposable
|
||||
{
|
||||
var tasks = new[]
|
||||
{
|
||||
_httpClient.DeleteAsync("anyurl"),
|
||||
_httpClient.DeleteAsync("anyurl"),
|
||||
_httpClient.GetAsync("anyurl")
|
||||
_httpClient.DeleteAsync("anyurl", _ct),
|
||||
_httpClient.DeleteAsync("anyurl", _ct),
|
||||
_httpClient.GetAsync("anyurl", _ct)
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
@@ -542,7 +543,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingOptions_Should_ThrowWhenCallsWereNotMadeUsingOptions()
|
||||
{
|
||||
await _httpClient.PostAsync("anyurl", new StringContent("anycontent"));
|
||||
await _httpClient.PostAsync("anyurl", new StringContent("anycontent"), _ct);
|
||||
|
||||
Action act = () => _server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -563,7 +564,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
|
||||
_httpClient.DefaultRequestHeaders.Add("Host", new Uri(_server.Urls[0]).Authority);
|
||||
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("CONNECT"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("CONNECT"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -574,7 +575,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingDelete_WhenACallWasMadeUsingDelete_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("DELETE"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("DELETE"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -584,7 +585,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingGet_WhenACallWasMadeUsingGet_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -594,7 +595,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingHead_WhenACallWasMadeUsingHead_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("HEAD"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("HEAD"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -604,7 +605,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingOptions_WhenACallWasMadeUsingOptions_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("OPTIONS"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("OPTIONS"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -616,7 +617,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"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod(method), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -646,9 +647,9 @@ public class WireMockAssertionsTests : IDisposable
|
||||
|
||||
var tasks = new[]
|
||||
{
|
||||
httpClient.GetAsync($"{server.Url}/a"),
|
||||
httpClient.PostAsync($"{server.Url}/b", new StringContent("B")),
|
||||
httpClient.PostAsync($"{server.Url}/c", new StringContent("C"))
|
||||
httpClient.GetAsync($"{server.Url}/a", _ct),
|
||||
httpClient.PostAsync($"{server.Url}/b", new StringContent("B"), _ct),
|
||||
httpClient.PostAsync($"{server.Url}/c", new StringContent("C"), _ct)
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
@@ -701,7 +702,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingPatch_WhenACallWasMadeUsingPatch_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -711,7 +712,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingPut_WhenACallWasMadeUsingPut_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PUT"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("PUT"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -721,7 +722,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingTrace_WhenACallWasMadeUsingTrace_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("TRACE"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("TRACE"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -731,7 +732,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
[Fact]
|
||||
public async Task HaveReceivedACall_UsingAnyMethod_WhenACallWasMadeUsingGet_Should_BeOK()
|
||||
{
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"));
|
||||
await _httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), "anyurl"), _ct);
|
||||
|
||||
_server.Should()
|
||||
.HaveReceivedACall()
|
||||
@@ -779,7 +780,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
// Act
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("x"));
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("x"), _ct);
|
||||
|
||||
// Assert
|
||||
server
|
||||
@@ -834,7 +835,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
{
|
||||
x = "y"
|
||||
};
|
||||
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody);
|
||||
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody, _ct);
|
||||
|
||||
// Assert
|
||||
server
|
||||
@@ -889,7 +890,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
{
|
||||
x = "123"
|
||||
};
|
||||
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody);
|
||||
await httpClient.PostAsJsonAsync($"{server.Url}/a", requestBody, _ct);
|
||||
|
||||
// Assert
|
||||
Action act = () => server
|
||||
@@ -920,7 +921,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
// Act
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("123"));
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("123"), _ct);
|
||||
|
||||
// Assert
|
||||
Action act = () => server
|
||||
@@ -951,7 +952,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
// Act
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
await httpClient.PostAsync($"{server.Url}/a", new ByteArrayContent([5]));
|
||||
await httpClient.PostAsync($"{server.Url}/a", new ByteArrayContent([5]), _ct);
|
||||
|
||||
// Assert
|
||||
Action act = () => server
|
||||
@@ -982,7 +983,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
// Act
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
await httpClient.PutAsync($"{server.Url}/a", new ByteArrayContent([100]));
|
||||
await httpClient.PutAsync($"{server.Url}/a", new ByteArrayContent([100]), _ct);
|
||||
|
||||
// Assert
|
||||
server
|
||||
@@ -1025,7 +1026,7 @@ public class WireMockAssertionsTests : IDisposable
|
||||
// Act
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("x"));
|
||||
await httpClient.PostAsync($"{server.Url}/a", new StringContent("x"), _ct);
|
||||
|
||||
// Assert
|
||||
server
|
||||
@@ -1063,13 +1064,13 @@ public class WireMockAssertionsTests : IDisposable
|
||||
|
||||
// Act : HTTP GET
|
||||
using var httpClient = new HttpClient();
|
||||
await httpClient.GetAsync(server.Url!);
|
||||
await httpClient.GetAsync(server.Url, _ct);
|
||||
|
||||
// Act : HTTP POST
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, server.Url!);
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, server.Url);
|
||||
request.Headers.Add("TestHeader", ["Value", "Value2"]);
|
||||
|
||||
await httpClient.SendAsync(request);
|
||||
await httpClient.SendAsync(request, _ct);
|
||||
|
||||
// Assert
|
||||
server.Should().HaveReceivedACall().UsingPost().And.WithHeader("TestHeader", ["Value", "Value2"]);
|
||||
@@ -1088,13 +1089,13 @@ public class WireMockAssertionsTests : IDisposable
|
||||
|
||||
// Act : HTTP GET
|
||||
using var httpClient = new HttpClient();
|
||||
await httpClient.GetAsync(server.Url!);
|
||||
await httpClient.GetAsync(server.Url, _ct);
|
||||
|
||||
// Act : HTTP POST
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, server.Url!);
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, server.Url);
|
||||
request.Headers.Add("TestHeader", ["Value", "Value2"]);
|
||||
|
||||
await httpClient.SendAsync(request);
|
||||
await httpClient.SendAsync(request, _ct);
|
||||
|
||||
// Assert
|
||||
server.Should().HaveReceivedACall().UsingPost().And.WitHeaderKey("TestHeader");
|
||||
|
||||
Reference in New Issue
Block a user