Jhkim/updatetest (#155)
* Added new test scenarios for websocket * Fixed test issues * Fixed test issues
This commit is contained in:
parent
c5f59e06c3
commit
0120dae36b
|
|
@ -1484,7 +1484,7 @@ namespace AspNetCoreModule.Test
|
||||||
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
||||||
|
|
||||||
// Verify text data is matched to the string sent by server
|
// 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;
|
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
||||||
|
|
||||||
// Verify text data is matched to the string sent by server
|
// 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
|
// Verify the application file can be removed under app_offline mode
|
||||||
testSite.AspNetCoreApp.BackupFile(appDllFileName);
|
testSite.AspNetCoreApp.BackupFile(appDllFileName);
|
||||||
|
|
@ -1576,7 +1576,7 @@ namespace AspNetCoreModule.Test
|
||||||
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
||||||
|
|
||||||
// Verify text data is matched to the string sent by server
|
// 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())
|
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);
|
Assert.DoesNotContain("Connection: Upgrade", frameReturned.Content);
|
||||||
|
|
||||||
//BugBug: Currently we returns 101 here.
|
//BugBug: Currently we returns 101 here.
|
||||||
|
|
@ -1795,7 +1795,7 @@ namespace AspNetCoreModule.Test
|
||||||
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
int lastIndex = websocketClient.Connection.DataReceived.Count - 1;
|
||||||
|
|
||||||
// Verify text data is matched to the string sent by server
|
// 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
|
// send a simple request and verify the response body
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,9 @@ namespace AspNetCoreModule.Test.WebSocketClient
|
||||||
|
|
||||||
public FrameType FrameType { get; set; }
|
public FrameType FrameType { get; set; }
|
||||||
public byte[] Data { get; private set; }
|
public byte[] Data { get; private set; }
|
||||||
|
|
||||||
public string TextData {
|
public string TextData
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (DataLength == 0)
|
if (DataLength == 0)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace AspNetCoreModule.Test.WebSocketClient
|
||||||
return result;
|
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;
|
Address = address;
|
||||||
StoreData = storeData;
|
StoreData = storeData;
|
||||||
|
|
@ -72,9 +72,25 @@ namespace AspNetCoreModule.Test.WebSocketClient
|
||||||
}
|
}
|
||||||
SendWebSocketRequest(WebSocketClientUtility.WebSocketVersion);
|
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;
|
Frame openingFrame = null;
|
||||||
|
|
@ -83,8 +99,7 @@ namespace AspNetCoreModule.Test.WebSocketClient
|
||||||
openingFrame = ReadData();
|
openingFrame = ReadData();
|
||||||
else
|
else
|
||||||
openingFrame = Connection.DataReceived[0];
|
openingFrame = Connection.DataReceived[0];
|
||||||
|
|
||||||
IsOpened = true;
|
|
||||||
return openingFrame;
|
return openingFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||||
<RuntimeFrameworkVersion>1.0.5</RuntimeFrameworkVersion>
|
<RuntimeFrameworkVersion>1.0.5</RuntimeFrameworkVersion>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue