Skip to content

Commit 9b76b8a

Browse files
committed
add integration tests for socket.io v2 polling
1 parent 3bdf187 commit 9b76b8a

18 files changed

+808
-3
lines changed

src/SocketIOClient.Sample/Program.cs

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

1718
var uri = new Uri("http://localhost:11002/");
1819

@@ -23,7 +24,6 @@ static async Task Main(string[] args)
2324
{"token", "V2" }
2425
},
2526
AutoUpgrade = false,
26-
EIO = 3
2727
});
2828

2929
socket.OnConnected += Socket_OnConnected;
@@ -69,8 +69,8 @@ private static async void Socket_OnConnected(object sender, EventArgs e)
6969
//while (true)
7070
//{
7171
// await Task.Delay(1000);
72-
await socket.EmitAsync("hi", DateTime.Now.ToShortDateString());
73-
//await socket.EmitAsync("welcome");
72+
//await socket.EmitAsync("hi", DateTime.Now.ToShortDateString());
73+
await socket.EmitAsync("welcome");
7474
//}
7575
//byte[] bytes = Encoding.UTF8.GetBytes("ClientCallsServerCallback_1Params_0");
7676
//await socket.EmitAsync("client calls the server's callback 1", bytes);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Threading.Tasks;
3+
4+
namespace SocketIOClient.Test.SocketIOTests.V2Http
5+
{
6+
[TestClass]
7+
public class DisconnectionV2NspTest : DisconnectionHttpTest
8+
{
9+
public DisconnectionV2NspTest()
10+
{
11+
SocketIOCreator = new SocketIOV2NspCreator();
12+
}
13+
14+
protected override ISocketIOCreateable SocketIOCreator { get; }
15+
16+
[TestMethod]
17+
public override async Task ClientDisconnect()
18+
{
19+
await base.ClientDisconnect();
20+
}
21+
22+
[TestMethod]
23+
public override async Task ServerDisconnect()
24+
{
25+
await base.ServerDisconnect();
26+
}
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Threading.Tasks;
3+
4+
namespace SocketIOClient.Test.SocketIOTests.V2Http
5+
{
6+
[TestClass]
7+
public class DisconnectionV2Test : DisconnectionHttpTest
8+
{
9+
public DisconnectionV2Test()
10+
{
11+
SocketIOCreator = new SocketIOV2Creator();
12+
}
13+
14+
protected override ISocketIOCreateable SocketIOCreator { get; }
15+
16+
[TestMethod]
17+
public override async Task ClientDisconnect()
18+
{
19+
await base.ClientDisconnect();
20+
}
21+
22+
[TestMethod]
23+
public override async Task ServerDisconnect()
24+
{
25+
await base.ServerDisconnect();
26+
}
27+
}
28+
}
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Threading.Tasks;
3+
4+
namespace SocketIOClient.Test.SocketIOTests.V2Http
5+
{
6+
[TestClass]
7+
public class EmitV2NspTest : EmitTest
8+
{
9+
public EmitV2NspTest()
10+
{
11+
SocketIOCreator = new SocketIOV2NspCreator();
12+
}
13+
14+
protected override ISocketIOCreateable SocketIOCreator { get; }
15+
16+
[TestMethod]
17+
public override async Task Hi()
18+
{
19+
await base.Hi();
20+
}
21+
22+
[TestMethod]
23+
public override async Task EmitWithoutParams()
24+
{
25+
await base.EmitWithoutParams();
26+
}
27+
28+
#region Emit with 1 params
29+
[TestMethod]
30+
public override async Task EmitWith1ParamsNull()
31+
{
32+
await base.EmitWith1ParamsNull();
33+
}
34+
35+
[TestMethod]
36+
public override async Task EmitWith1ParamsTrue()
37+
{
38+
await base.EmitWith1ParamsTrue();
39+
}
40+
41+
[TestMethod]
42+
public override async Task EmitWith1ParamsFalse()
43+
{
44+
await base.EmitWith1ParamsFalse();
45+
}
46+
47+
[TestMethod]
48+
public override async Task EmitWith1ParamsNumber0()
49+
{
50+
await base.EmitWith1ParamsNumber0();
51+
}
52+
53+
[TestMethod]
54+
public override async Task EmitWith1ParamsNumberMin()
55+
{
56+
await base.EmitWith1ParamsNumberMin();
57+
}
58+
59+
[TestMethod]
60+
public override async Task EmitWith1ParamsNumberMax()
61+
{
62+
await base.EmitWith1ParamsNumberMax();
63+
}
64+
65+
[TestMethod]
66+
public override async Task EmitWith1ParamsEmptyString()
67+
{
68+
await base.EmitWith1ParamsEmptyString();
69+
}
70+
71+
[TestMethod]
72+
public override async Task EmitWith1ParamsShortString()
73+
{
74+
await base.EmitWith1ParamsShortString();
75+
}
76+
77+
[TestMethod]
78+
public override async Task EmitWith1ParamsLongString()
79+
{
80+
await base.EmitWith1ParamsLongString();
81+
}
82+
83+
[TestMethod]
84+
public override async Task EmitWith1ParamsEmptyObject()
85+
{
86+
await base.EmitWith1ParamsEmptyObject();
87+
}
88+
89+
[TestMethod]
90+
public override async Task EmitWith1ParamsObject()
91+
{
92+
await base.EmitWith1ParamsObject();
93+
}
94+
95+
[TestMethod]
96+
public override async Task EmitWith1ParamsBytes()
97+
{
98+
await base.EmitWith1ParamsBytes();
99+
}
100+
101+
[TestMethod]
102+
public override async Task EmitWith1ParamsBytesInObject()
103+
{
104+
await base.EmitWith1ParamsBytesInObject();
105+
}
106+
107+
[TestMethod]
108+
public override async Task EmitWith2ParamsBytes()
109+
{
110+
await base.EmitWith2ParamsBytes();
111+
}
112+
113+
[TestMethod]
114+
public override async Task EmitWith1ParamsArray()
115+
{
116+
await base.EmitWith1ParamsArray();
117+
}
118+
#endregion
119+
120+
#region Emit with 2 params
121+
[TestMethod]
122+
public override async Task EmitWith2ParamsNull()
123+
{
124+
await base.EmitWith2ParamsNull();
125+
}
126+
127+
[TestMethod]
128+
public override async Task EmitWith2ParamsTrueTrue()
129+
{
130+
await base.EmitWith2ParamsTrueTrue();
131+
}
132+
133+
[TestMethod]
134+
public override async Task EmitWith2ParamsTrueFalse()
135+
{
136+
await base.EmitWith2ParamsTrueFalse();
137+
}
138+
139+
[TestMethod]
140+
public override async Task EmitWith2ParamsFalseTrue()
141+
{
142+
await base.EmitWith2ParamsFalseTrue();
143+
}
144+
145+
[TestMethod]
146+
public override async Task EmitWith2ParamsTrueNull()
147+
{
148+
await base.EmitWith2ParamsTrueNull();
149+
}
150+
151+
[TestMethod]
152+
public override async Task EmitWith2ParamsStringObject()
153+
{
154+
await base.EmitWith2ParamsStringObject();
155+
}
156+
157+
[TestMethod]
158+
public override async Task EmitWith2ParamsArrayAndString()
159+
{
160+
await base.EmitWith2ParamsArrayAndString();
161+
}
162+
#endregion
163+
164+
#region Server calls the client's callback
165+
[TestMethod]
166+
public override async Task NoParams_NoParams()
167+
{
168+
await base.NoParams_NoParams();
169+
}
170+
171+
[TestMethod]
172+
public override async Task OneParams_OneParams_String()
173+
{
174+
await base.OneParams_OneParams_String();
175+
}
176+
177+
[TestMethod]
178+
public override async Task TwoParams_TwoParams_StringObject()
179+
{
180+
await base.TwoParams_TwoParams_StringObject();
181+
}
182+
183+
[TestMethod]
184+
public override async Task TwoParams_TwoParams_2Binary()
185+
{
186+
await base.TwoParams_TwoParams_2Binary();
187+
}
188+
189+
[TestMethod]
190+
public override async Task ClientCallsServerCallback_NoParams_0()
191+
{
192+
await base.ClientCallsServerCallback_NoParams_0();
193+
}
194+
195+
[TestMethod]
196+
public override async Task ClientCallsServerCallback_NoParams_1()
197+
{
198+
await base.ClientCallsServerCallback_NoParams_1();
199+
}
200+
201+
[TestMethod]
202+
public override async Task ClientCallsServerCallback_1Params_0()
203+
{
204+
await base.ClientCallsServerCallback_1Params_0();
205+
}
206+
#endregion
207+
}
208+
}

0 commit comments

Comments
 (0)