Skip to content

Commit b2361ed

Browse files
committed
fix tests
1 parent c3096fb commit b2361ed

38 files changed

+336
-256
lines changed

src/SocketIOClient.Sample/Program.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,30 @@ static async Task Main(string[] args)
1313
{
1414
//Console.OutputEncoding = Encoding.UTF8;
1515
//Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
16-
1716

18-
var uri = new Uri("http://localhost:11002/");
17+
18+
//var uri = new Uri("http://localhost:11003/nsp");
19+
20+
//var socket = new SocketIO(uri, new SocketIOOptions
21+
//{
22+
// Query = new Dictionary<string, string>
23+
// {
24+
// {"token", "V3NSP" }
25+
// },
26+
// //EIO = 3,
27+
// Transport = Transport.TransportProtocol.Polling
28+
//});
29+
30+
var uri = new Uri("http://localhost:11002/nsp");
1931

2032
var socket = new SocketIO(uri, new SocketIOOptions
2133
{
2234
Query = new Dictionary<string, string>
2335
{
2436
{"token", "V2" }
2537
},
26-
AutoUpgrade = false,
38+
EIO = 3,
39+
Transport = Transport.TransportProtocol.Polling
2740
});
2841

2942
socket.OnConnected += Socket_OnConnected;
@@ -69,8 +82,8 @@ private static async void Socket_OnConnected(object sender, EventArgs e)
6982
//while (true)
7083
//{
7184
// await Task.Delay(1000);
72-
//await socket.EmitAsync("hi", DateTime.Now.ToShortDateString());
73-
await socket.EmitAsync("welcome");
85+
await socket.EmitAsync("hi", DateTime.Now.ToString());
86+
//await socket.EmitAsync("welcome");
7487
//}
7588
//byte[] bytes = Encoding.UTF8.GetBytes("ClientCallsServerCallback_1Params_0");
7689
//await socket.EmitAsync("client calls the server's callback 1", bytes);

src/SocketIOClient.Test/SocketIOTests/DisconnectionHttpTest.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ public abstract class DisconnectionHttpTest
1111
public virtual async Task ServerDisconnect()
1212
{
1313
string reason = null;
14-
var client = new SocketIO(SocketIOCreator.Url, new SocketIOOptions
15-
{
16-
Reconnection = false,
17-
AutoUpgrade = false,
18-
Query = new Dictionary<string, string>
19-
{
20-
{ "token", SocketIOCreator.Token }
21-
}
22-
});
14+
var client = SocketIOCreator.Create();
2315

2416
Assert.IsFalse(client.Connected);
2517
Assert.IsTrue(client.Disconnected);
@@ -40,20 +32,13 @@ public virtual async Task ServerDisconnect()
4032
Assert.IsFalse(client.Connected);
4133
Assert.IsTrue(client.Disconnected);
4234
Assert.AreEqual("io server disconnect", reason);
35+
client.Dispose();
4336
}
4437

4538
public virtual async Task ClientDisconnect()
4639
{
4740
string reason = null;
48-
var client = new SocketIO(SocketIOCreator.Url, new SocketIOOptions
49-
{
50-
Reconnection = false,
51-
AutoUpgrade = false,
52-
Query = new Dictionary<string, string>
53-
{
54-
{ "token", SocketIOCreator.Token }
55-
}
56-
});
41+
var client = SocketIOCreator.Create();
5742

5843
Assert.IsFalse(client.Connected);
5944
Assert.IsTrue(client.Disconnected);
@@ -67,6 +52,7 @@ public virtual async Task ClientDisconnect()
6752
Assert.IsFalse(client.Connected);
6853
Assert.IsTrue(client.Disconnected);
6954
Assert.AreEqual("io client disconnect", reason);
55+
client.Dispose();
7056
}
7157
}
7258
}

src/SocketIOClient.Test/SocketIOTests/DisconnectionTest.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ public abstract class DisconnectionTest
1111
public virtual async Task ServerDisconnect()
1212
{
1313
string reason = null;
14-
var client = new SocketIO(SocketIOCreator.Url, new SocketIOOptions
15-
{
16-
Reconnection = false,
17-
Query = new Dictionary<string, string>
18-
{
19-
{ "token", SocketIOCreator.Token }
20-
}
21-
});
14+
var client = SocketIOCreator.Create();
2215

2316
Assert.IsFalse(client.Connected);
2417
Assert.IsTrue(client.Disconnected);
@@ -39,19 +32,13 @@ public virtual async Task ServerDisconnect()
3932
Assert.IsFalse(client.Connected);
4033
Assert.IsTrue(client.Disconnected);
4134
Assert.AreEqual("io server disconnect", reason);
35+
client.Dispose();
4236
}
4337

4438
public virtual async Task ClientDisconnect()
4539
{
4640
string reason = null;
47-
var client = new SocketIO(SocketIOCreator.Url, new SocketIOOptions
48-
{
49-
Reconnection = false,
50-
Query = new Dictionary<string, string>
51-
{
52-
{ "token", SocketIOCreator.Token }
53-
}
54-
});
41+
var client = SocketIOCreator.Create();
5542

5643
Assert.IsFalse(client.Connected);
5744
Assert.IsTrue(client.Disconnected);
@@ -65,6 +52,7 @@ public virtual async Task ClientDisconnect()
6552
Assert.IsFalse(client.Connected);
6653
Assert.IsTrue(client.Disconnected);
6754
Assert.AreEqual("io client disconnect", reason);
55+
client.Dispose();
6856
}
6957
}
7058
}

0 commit comments

Comments
 (0)