You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@ -1,4 +1,3 @@
|
||||
#if NET_4_5
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
@ -19,31 +18,33 @@ namespace MonoTests.System.Net.WebSockets
|
||||
{
|
||||
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
|
||||
int Port = NetworkHelpers.FindFreePort ();
|
||||
HttpListener listener;
|
||||
ClientWebSocket socket;
|
||||
MethodInfo headerSetMethod;
|
||||
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:" + Port + "/");
|
||||
listener.Start ();
|
||||
socket = new ClientWebSocket ();
|
||||
HttpListener _listener;
|
||||
HttpListener listener {
|
||||
get {
|
||||
if (_listener != null)
|
||||
return _listener;
|
||||
var tmp = new HttpListener ();
|
||||
tmp.Prefixes.Add ("http://localhost:" + Port + "/");
|
||||
tmp.Start ();
|
||||
return _listener = tmp;
|
||||
}
|
||||
}
|
||||
ClientWebSocket _socket;
|
||||
ClientWebSocket socket { get { return _socket ?? (_socket = new ClientWebSocket ()); } }
|
||||
MethodInfo headerSetMethod;
|
||||
|
||||
[TearDown]
|
||||
public void Teardown ()
|
||||
{
|
||||
if (listener != null) {
|
||||
listener.Stop ();
|
||||
listener = null;
|
||||
if (_listener != null) {
|
||||
_listener.Stop ();
|
||||
_listener = null;
|
||||
}
|
||||
if (socket != null) {
|
||||
if (socket.State == WebSocketState.Open)
|
||||
socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
|
||||
socket.Dispose ();
|
||||
socket = null;
|
||||
if (_socket != null) {
|
||||
if (_socket.State == WebSocketState.Open)
|
||||
_socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
|
||||
_socket.Dispose ();
|
||||
_socket = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,4 +298,3 @@ namespace MonoTests.System.Net.WebSockets
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user