This commit is contained in:
Stef Heyenrath
2026-02-21 17:21:18 +01:00
parent 43a26ec4bc
commit 43be85a88a
27 changed files with 306 additions and 281 deletions

View File

@@ -17,6 +17,8 @@ namespace WireMock.Net.Tests;
public class WireMockServerWebhookTests
{
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
[Fact]
public async Task WireMockServer_WithWebhooks_Should_Send_Message_To_Webhooks()
{
@@ -71,8 +73,8 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
@@ -120,8 +122,8 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
@@ -176,8 +178,8 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
@@ -231,8 +233,8 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
@@ -263,14 +265,14 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
serverReceivingTheWebhook.LogEntries.Should().HaveCount(1);
serverReceivingTheWebhook.LogEntries.First().RequestMessage.Body.Should().Be("OK !");
serverReceivingTheWebhook.LogEntries.First().RequestMessage!.Body.Should().Be("OK !");
server.Dispose();
serverReceivingTheWebhook.Dispose();
@@ -297,14 +299,14 @@ public class WireMockServerWebhookTests
};
// Assert
var response = await new HttpClient().SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var response = await new HttpClient().SendAsync(request, _ct);
var content = await response.Content.ReadAsStringAsync(_ct);
response.StatusCode.Should().Be(HttpStatusCode.OK);
content.Should().Be("a-response");
serverReceivingTheWebhook.LogEntries.Should().HaveCount(1);
serverReceivingTheWebhook.LogEntries.First().RequestMessage.Body.Should().Be("{\"Status\":\"OK\"}");
serverReceivingTheWebhook.LogEntries.First().RequestMessage!.Body.Should().Be("{\"Status\":\"OK\"}");
server.Dispose();
serverReceivingTheWebhook.Dispose();