Skip to content

Commit 5522acf

Browse files
committed
optimized the unit test TestCloseAfterSend
1 parent 1222ef3 commit 5522acf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/SuperSocket.Tests/MainTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,22 +418,22 @@ public async Task TestCloseAfterSend(Type hostConfiguratorType)
418418
await s.CloseAsync(CloseReason.LocalClosing);
419419
}).BuildAsServer() as IServer)
420420
{
421-
Assert.True(await server.StartAsync());
421+
Assert.True(await server.StartAsync(TestContext.Current.CancellationToken));
422422
Assert.Equal(0, server.SessionCount);
423423

424424
var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
425-
await client.ConnectAsync(hostConfigurator.GetServerEndPoint());
425+
await client.ConnectAsync(hostConfigurator.GetServerEndPoint(), TestContext.Current.CancellationToken);
426426
using (var stream = await hostConfigurator.GetClientStream(client))
427427
using (var streamReader = new StreamReader(stream, Utf8Encoding, true))
428428
using (var streamWriter = new StreamWriter(stream, Utf8Encoding, 1024 * 1024 * 4))
429429
{
430430
await streamWriter.WriteAsync("Hello World\r\n");
431-
await streamWriter.FlushAsync();
432-
var line = await streamReader.ReadLineAsync();
431+
await streamWriter.FlushAsync(TestContext.Current.CancellationToken);
432+
var line = await streamReader.ReadLineAsync(TestContext.Current.CancellationToken);
433433
Assert.Equal("Hello World", line);
434434
}
435435

436-
await server.StopAsync();
436+
await server.StopAsync(TestContext.Current.CancellationToken);
437437
}
438438
}
439439

0 commit comments

Comments
 (0)