This commit is contained in:
Stef Heyenrath
2026-02-26 19:05:02 +01:00
parent 5c437450a1
commit ad0ec81e35
2 changed files with 16 additions and 35 deletions

View File

@@ -808,8 +808,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
receivedData.Should().BeEquivalentTo(testData, "binary data should be proxied and echoed back");
await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(100, _ct);
}
[Fact]
@@ -863,6 +861,8 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client2.ConnectAsync(uri, _ct);
await client3.ConnectAsync(uri, _ct);
await Task.Delay(500, _ct);
await client1.SendAsync("register", cancellationToken: _ct);
await client2.SendAsync("register", cancellationToken: _ct);
await client3.SendAsync("register", cancellationToken: _ct);
@@ -891,8 +891,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client3.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(300, _ct);
}
[Fact]
@@ -941,6 +939,8 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client2.ConnectAsync(uri, _ct);
await client3.ConnectAsync(uri, _ct);
await Task.Delay(500, _ct);
await client1.SendAsync("register", cancellationToken: _ct);
await client2.SendAsync("register", cancellationToken: _ct);
await client3.SendAsync("register", cancellationToken: _ct);
@@ -969,8 +969,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client3.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(300, _ct);
}
[Fact]
@@ -1026,8 +1024,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(300, _ct);
}
[Fact]
@@ -1090,8 +1086,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -1137,8 +1131,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
received.Should().Be(broadcastMessage);
await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(100, _ct);
}
[Fact]
@@ -1183,6 +1175,8 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
// Act - disconnect client1
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Disconnecting", _ct);
await Task.Delay(500, _ct);
// Send broadcast from client2 - should handle disconnected client gracefully
await client2.SendAsync(broadcastMessage, cancellationToken: _ct);
@@ -1191,8 +1185,6 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
received2.Should().Be(broadcastMessage);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -1254,7 +1246,5 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
}

View File

@@ -48,6 +48,8 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client2.ConnectAsync(uri, _ct);
await client3.ConnectAsync(uri, _ct);
await Task.Delay(500, _ct);
// Assert
var connections = server.GetWebSocketConnections();
connections.Should().HaveCount(3);
@@ -56,8 +58,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client3.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(300, _ct);
}
[Fact]
@@ -140,6 +140,8 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client2.ConnectAsync(uri1, _ct);
await client3.ConnectAsync(uri2, _ct);
await Task.Delay(500, _ct);
// Assert
var allConnections = server.GetWebSocketConnections();
allConnections.Should().HaveCount(3);
@@ -153,8 +155,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client3.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(300, _ct);
}
[Fact]
@@ -187,6 +187,8 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.ConnectAsync(uri, _ct);
await client2.ConnectAsync(uri, _ct);
await Task.Delay(500, _ct);
var connections = server.GetWebSocketConnections();
connections.Should().HaveCount(2);
@@ -200,8 +202,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
remainingConnections.Should().HaveCount(1);
var remainingConnection = remainingConnections.First();
remainingConnection.ConnectionId.Should().NotBe(connectionIdToAbort);
await Task.Delay(200, _ct);
}
[Fact]
@@ -270,8 +270,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -340,8 +338,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -430,8 +426,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -520,8 +514,6 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
[Fact]
@@ -552,23 +544,22 @@ public class WireMockServerWebSocketIntegrationTests(ITestOutputHelper output, I
var uri = new Uri($"{server.Url}/ws/test");
await client1.ConnectAsync(uri, _ct);
await Task.Delay(100, _ct);
await client2.ConnectAsync(uri, _ct);
await Task.Delay(100, _ct);
await Task.Delay(500, _ct);
var initialConnections = server.GetWebSocketConnections();
initialConnections.Should().HaveCount(2);
// Act
await client1.CloseAsync(WebSocketCloseStatus.NormalClosure, "Disconnect", _ct);
await Task.Delay(100, _ct);
await Task.Delay(500, _ct);
// Assert
var remainingConnections = server.GetWebSocketConnections();
remainingConnections.Should().HaveCount(1);
await client2.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(200, _ct);
}
}