more tsts

This commit is contained in:
Stef Heyenrath
2026-02-24 22:51:04 +01:00
parent ba3d1d758c
commit 107e649ec0
4 changed files with 306 additions and 7 deletions

View File

@@ -15,6 +15,36 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
{
private readonly CancellationToken _ct = testContext.Current.CancellationToken;
[Fact]
public async Task WithNoSetupShouldJustWaitForClose_AndCLose_When_ClientCloses()
{
// Arrange
using var server = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(output),
Urls = ["ws://localhost:0"]
});
server
.Given(Request.Create()
.WithPath("/ws/x")
.WithWebSocketUpgrade()
)
.RespondWith(Response.Create()
.WithWebSocket(_ => { })
);
using var client = new ClientWebSocket();
var uri = new Uri($"{server.Url}/ws/x");
// Act
await client.ConnectAsync(uri, _ct);
client.State.Should().Be(WebSocketState.Open);
// Assert
await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
}
[Fact]
public async Task EchoServer_Should_Echo_Text_Messages()
{
@@ -40,7 +70,7 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
var uri = new Uri($"{server.Url}/ws/echo");
// Act
await client.ConnectAsync(uri, CancellationToken.None);
await client.ConnectAsync(uri, _ct);
client.State.Should().Be(WebSocketState.Open);
var testMessage = "Hello, WebSocket!";
@@ -906,7 +936,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
var uri = new Uri($"{server.Url}/ws/broadcast");
// Act
await client1.ConnectAsync(uri, _ct);
await client2.ConnectAsync(uri, _ct);
await client3.ConnectAsync(uri, _ct);