From eb2fa9bacd35359728bee6963e584e1fa81c993a Mon Sep 17 00:00:00 2001 From: Mikael Mengistu Date: Wed, 28 Mar 2018 15:27:40 -0700 Subject: [PATCH] Fix more flaky tests (#1750) --- .../HttpConnectionTests.ConnectionLifecycle.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HttpConnectionTests.ConnectionLifecycle.cs b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HttpConnectionTests.ConnectionLifecycle.cs index c20434f55d..67e0e02428 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HttpConnectionTests.ConnectionLifecycle.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HttpConnectionTests.ConnectionLifecycle.cs @@ -83,13 +83,22 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests [Theory] [InlineData(2)] [InlineData(3)] - public async Task TransportThatFailsToStartOnceFallsBack(int passThreshold) + public async Task TransportThatFailsToStartFallsBack(int passThreshold) { using (StartLog(out var loggerFactory)) { var startCounter = 0; var expected = new Exception("Transport failed to start"); + // We have 4 cases here. Falling back once, falling back twice and each of these + // with WebSockets available and not. If Websockets aren't available and + // we can't to test the fallback once scenario we don't decrement the passthreshold + // because we still try to start twice (SSE and LP). + if (!IsWebSocketsSupported() && passThreshold > 2) + { + passThreshold -= 1; + } + Task OnTransportStart() { startCounter++; @@ -112,11 +121,6 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { Assert.Equal(0, startCounter); await connection.StartAsync(TransferFormat.Text); - if (!IsWebSocketsSupported()) - { - passThreshold -= 1; - } - Assert.Equal(passThreshold, startCounter); }); }