@@ -56,15 +56,15 @@ public async Task TestClientDisconnectionFromServer()
5656
5757 Assert . True ( server . IsRunning ) ;
5858 Assert . True ( client . IsConnected ) ;
59- // Wait a second for connection acceptance
60- await Task . Delay ( 1000 ) ;
59+ // Wait a bit for connection acceptance
60+ await Task . Delay ( 10 ) ;
6161 Assert . Equal ( 1 , server . ConnectionManager . ConnectionCount ) ;
6262
63- await server . DisconnectAsync ( 1 ) ;
63+ await server . DisconnectAsync ( server . ConnectionManager . GetAllConnections ( ) . First ( ) . ConnectionId ) ;
6464 Assert . Equal ( 0 , server . ConnectionManager . ConnectionCount ) ;
6565
66- // Wait a second for disconnection
67- await Task . Delay ( 1000 ) ;
66+ // Wait a bit for disconnection
67+ await Task . Delay ( 10 ) ;
6868 Assert . False ( client . IsConnected ) ;
6969
7070 await server . StopAsync ( ) ;
@@ -86,13 +86,13 @@ public async Task TestClientDisconnectionFromClient()
8686
8787 Assert . True ( server . IsRunning ) ;
8888 Assert . True ( client . IsConnected ) ;
89- // Wait a second for connection acceptance
90- await Task . Delay ( 1000 ) ;
89+ // Wait a bit for connection acceptance
90+ await Task . Delay ( 10 ) ;
9191 Assert . Equal ( 1 , server . ConnectionManager . ConnectionCount ) ;
9292
9393 await client . DisconnectAsync ( ) ;
94- // Wait a second for disconnection
95- await Task . Delay ( 1000 ) ;
94+ // Wait a bit for disconnection
95+ await Task . Delay ( 10 ) ;
9696 Assert . Equal ( 0 , server . ConnectionManager . ConnectionCount ) ;
9797
9898 Assert . False ( client . IsConnected ) ;
@@ -127,8 +127,8 @@ await client.SendMessageAsync(new TestMessage()
127127 stringVal = "HelloMsgClient" ,
128128 } ) ;
129129
130- // Wait a second for message sending
131- await Task . Delay ( 1000 ) ;
130+ // Wait a bit for message sending
131+ await Task . Delay ( 10 ) ;
132132 Assert . Equal ( "HelloMsgClient" , serverTestMsgHandler . stringVal ) ;
133133
134134 await client . DisconnectAsync ( ) ;
@@ -157,17 +157,17 @@ public async Task TestMessageFromServerHandling()
157157 Assert . True ( server . IsRunning ) ;
158158 Assert . True ( client . IsConnected ) ;
159159
160- // Wait a second for connection acceptance
161- await Task . Delay ( 1000 ) ;
160+ // Wait a bit for connection acceptance
161+ await Task . Delay ( 10 ) ;
162162 Assert . Equal ( 1 , server . ConnectionManager . ConnectionCount ) ;
163163
164- await server . SendMessageAsync ( 1 , new TestMessage ( )
164+ await server . SendMessageAsync ( server . ConnectionManager . GetAllConnections ( ) . First ( ) . ConnectionId , new TestMessage ( )
165165 {
166166 stringVal = "HelloMsgFromServer" ,
167167 } ) ;
168168
169- // Wait a second for message sending
170- await Task . Delay ( 1000 ) ;
169+ // Wait a bit for message sending
170+ await Task . Delay ( 10 ) ;
171171 Assert . Equal ( "HelloMsgFromServer" , clientTestMsgHandler . stringVal ) ;
172172
173173 await client . DisconnectAsync ( ) ;
@@ -192,11 +192,9 @@ public async Task TestReuseClientConnection()
192192 var clientCancelSrc = new CancellationTokenSource ( ) ;
193193 await client . ConnectAsync ( "127.0.0.1" , 7895 , clientCancelSrc . Token ) ;
194194 // Wait a bit for connection acceptance
195- await Task . Delay ( 100 ) ;
196195 Assert . True ( client . IsConnected ) ;
197196 await client . DisconnectAsync ( ) ;
198197 // Wait a bit for disconnection
199- await Task . Delay ( 100 ) ;
200198 Assert . False ( client . IsConnected ) ;
201199 }
202200
@@ -219,24 +217,22 @@ public async Task TestClientMaxConnections()
219217 var client1 = new TcpNetworkClient ( _loggerFactoryMock . Object ) ;
220218 var clientCancelSrc = new CancellationTokenSource ( ) ;
221219 await client1 . ConnectAsync ( "127.0.0.1" , 7896 , clientCancelSrc . Token ) ;
222- // Wait a second for connection acceptance
223- await Task . Delay ( 1000 ) ;
220+ // Wait a bit for connection acceptance
224221 Assert . True ( client1 . IsConnected ) ;
225222
226223 // Client 2 - must be able to connection
227224 var client2 = new TcpNetworkClient ( _loggerFactoryMock . Object ) ;
228225 clientCancelSrc = new CancellationTokenSource ( ) ;
229226 await client2 . ConnectAsync ( "127.0.0.1" , 7896 , clientCancelSrc . Token ) ;
230- // Wait a second for connection acceptance
231- await Task . Delay ( 1000 ) ;
227+ // Wait a bit for connection acceptance
232228 Assert . True ( client2 . IsConnected ) ;
233229
234230 // Client 3 - must not be able to connection
235231 var client3 = new TcpNetworkClient ( _loggerFactoryMock . Object ) ;
236232 clientCancelSrc = new CancellationTokenSource ( ) ;
237233 await client3 . ConnectAsync ( "127.0.0.1" , 7896 , clientCancelSrc . Token ) ;
238- // Wait a second for connection acceptance
239- await Task . Delay ( 1000 ) ;
234+ // Wait a bit for connection acceptance
235+ await Task . Delay ( 10 ) ;
240236 Assert . False ( client3 . IsConnected ) ;
241237
242238 await client1 . DisconnectAsync ( ) ;
0 commit comments