diff --git a/test/AspNetCoreModule.Test/FunctionalTestHelper.cs b/test/AspNetCoreModule.Test/FunctionalTestHelper.cs index 075774a83b..dcbd06adc3 100644 --- a/test/AspNetCoreModule.Test/FunctionalTestHelper.cs +++ b/test/AspNetCoreModule.Test/FunctionalTestHelper.cs @@ -1484,7 +1484,7 @@ namespace AspNetCoreModule.Test int lastIndex = websocketClient.Connection.DataReceived.Count - 1; // Verify text data is matched to the string sent by server - Assert.Equal("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); + Assert.Contains("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); } } @@ -1527,7 +1527,7 @@ namespace AspNetCoreModule.Test int lastIndex = websocketClient.Connection.DataReceived.Count - 1; // Verify text data is matched to the string sent by server - Assert.Equal("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); + Assert.Contains("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); // Verify the application file can be removed under app_offline mode testSite.AspNetCoreApp.BackupFile(appDllFileName); @@ -1576,7 +1576,7 @@ namespace AspNetCoreModule.Test int lastIndex = websocketClient.Connection.DataReceived.Count - 1; // Verify text data is matched to the string sent by server - Assert.Equal("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); + Assert.Contains("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); } } */ @@ -1601,7 +1601,7 @@ namespace AspNetCoreModule.Test using (WebSocketClientHelper websocketClient = new WebSocketClientHelper()) { - var frameReturned = websocketClient.Connect(testSite.AspNetCoreApp.GetUri("websocket"), true, true); + var frameReturned = websocketClient.Connect(testSite.AspNetCoreApp.GetUri("websocket"), true, true, waitForConnectionOpen:false); Assert.DoesNotContain("Connection: Upgrade", frameReturned.Content); //BugBug: Currently we returns 101 here. @@ -1795,7 +1795,7 @@ namespace AspNetCoreModule.Test int lastIndex = websocketClient.Connection.DataReceived.Count - 1; // Verify text data is matched to the string sent by server - Assert.Equal("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); + Assert.Contains("ClosingFromServer", websocketClient.Connection.DataReceived[lastIndex].TextData); } // send a simple request and verify the response body diff --git a/test/AspNetCoreModule.Test/WebSocketClientHelper/Frame.cs b/test/AspNetCoreModule.Test/WebSocketClientHelper/Frame.cs index 3f0fa9b755..5e7d66a9d5 100644 --- a/test/AspNetCoreModule.Test/WebSocketClientHelper/Frame.cs +++ b/test/AspNetCoreModule.Test/WebSocketClientHelper/Frame.cs @@ -20,8 +20,9 @@ namespace AspNetCoreModule.Test.WebSocketClient public FrameType FrameType { get; set; } public byte[] Data { get; private set; } - - public string TextData { + + public string TextData + { get { if (DataLength == 0) diff --git a/test/AspNetCoreModule.Test/WebSocketClientHelper/WebSocketClientHelper.cs b/test/AspNetCoreModule.Test/WebSocketClientHelper/WebSocketClientHelper.cs index ebd32f5ff0..76b038c792 100644 --- a/test/AspNetCoreModule.Test/WebSocketClientHelper/WebSocketClientHelper.cs +++ b/test/AspNetCoreModule.Test/WebSocketClientHelper/WebSocketClientHelper.cs @@ -60,7 +60,7 @@ namespace AspNetCoreModule.Test.WebSocketClient return result; } - public Frame Connect(Uri address, bool storeData, bool isAlwaysReading) + public Frame Connect(Uri address, bool storeData, bool isAlwaysReading, bool waitForConnectionOpen = true) { Address = address; StoreData = storeData; @@ -72,9 +72,25 @@ namespace AspNetCoreModule.Test.WebSocketClient } SendWebSocketRequest(WebSocketClientUtility.WebSocketVersion); - if (!WaitForWebSocketState(WebSocketState.ConnectionOpen)) + if (waitForConnectionOpen) { - throw new Exception("Failed to open a connection"); + if (!WaitForWebSocketState(WebSocketState.ConnectionOpen)) + { + throw new Exception("Failed to open a connection"); + } + } + else + { + Thread.Sleep(3000); + } + + if (this.WebSocketState == WebSocketState.ConnectionOpen) + { + IsOpened = true; + } + else + { + IsOpened = false; } Frame openingFrame = null; @@ -83,8 +99,7 @@ namespace AspNetCoreModule.Test.WebSocketClient openingFrame = ReadData(); else openingFrame = Connection.DataReceived[0]; - - IsOpened = true; + return openingFrame; } diff --git a/test/AspNetCoreModule.TestSites.Standard/AspNetCoreModule.TestSites.Standard.csproj b/test/AspNetCoreModule.TestSites.Standard/AspNetCoreModule.TestSites.Standard.csproj index 784d5e618c..bc68c4518c 100644 --- a/test/AspNetCoreModule.TestSites.Standard/AspNetCoreModule.TestSites.Standard.csproj +++ b/test/AspNetCoreModule.TestSites.Standard/AspNetCoreModule.TestSites.Standard.csproj @@ -1,4 +1,4 @@ - + netcoreapp1.0 1.0.5