Skip to content

Commit

Permalink
improved the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed Jan 20, 2025
1 parent 47dd09a commit f5f775f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test/SuperSocket.Tests/ProtocolTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public virtual async Task TestNormalRequest(Type hostConfiguratorType)

using (var server = CreateServer(hostConfigurator))
{
await server.StartAsync();
Assert.True(await server.StartAsync());

OutputHelper.WriteLine("The server has been started.");

using (var socket = CreateClient(hostConfigurator))
{
Expand All @@ -56,7 +58,7 @@ public virtual async Task TestNormalRequest(Type hostConfiguratorType)
writer.Write(CreateRequest(line));
writer.Flush();

var receivedLine = await reader.ReadLineAsync();
var receivedLine = await reader.ReadLineAsync(TestContext.Current.CancellationToken);
Assert.Equal(line, receivedLine);
}
}
Expand All @@ -78,7 +80,9 @@ public virtual async Task TestMiddleBreak(Type hostConfiguratorType)

using (var server = CreateServer(hostConfigurator))
{
await server.StartAsync();
Assert.True(await server.StartAsync());

OutputHelper.WriteLine("The server has been started.");

for (var i = 0; i < 100; i++)
{
Expand Down Expand Up @@ -114,7 +118,9 @@ public virtual async Task TestFragmentRequest(Type hostConfiguratorType)

using (var server = CreateServer(hostConfigurator))
{
await server.StartAsync();
Assert.True(await server.StartAsync());

OutputHelper.WriteLine("The server has been started.");

using (var socket = CreateClient(hostConfigurator))
{
Expand All @@ -133,7 +139,7 @@ public virtual async Task TestFragmentRequest(Type hostConfiguratorType)
await hostConfigurator.KeepSequence();
}

var receivedLine = await reader.ReadLineAsync();
var receivedLine = await reader.ReadLineAsync(TestContext.Current.CancellationToken);
Assert.Equal(line, receivedLine);
}
}
Expand All @@ -155,7 +161,9 @@ public virtual async Task TestBatchRequest(Type hostConfiguratorType)

using (var server = CreateServer(hostConfigurator))
{
await server.StartAsync();
Assert.True(await server.StartAsync());

OutputHelper.WriteLine("The server has been started.");

using (var socket = CreateClient(hostConfigurator))
{
Expand All @@ -181,7 +189,7 @@ public virtual async Task TestBatchRequest(Type hostConfiguratorType)

for (var i = 0; i < size; i++)
{
var receivedLine = await reader.ReadLineAsync();
var receivedLine = await reader.ReadLineAsync(TestContext.Current.CancellationToken);
Assert.Equal(lines[i], receivedLine);
}
}
Expand All @@ -204,7 +212,9 @@ public virtual async Task TestBreakRequest(Type hostConfiguratorType)

using (var server = CreateServer(hostConfigurator))
{
await server.StartAsync();
Assert.True(await server.StartAsync());

OutputHelper.WriteLine("The server has been started.");

using (var socket = CreateClient(hostConfigurator))
{
Expand Down Expand Up @@ -257,7 +267,7 @@ public virtual async Task TestBreakRequest(Type hostConfiguratorType)

for (var i = 0; i < size; i++)
{
var receivedLine = await reader.ReadLineAsync();
var receivedLine = await reader.ReadLineAsync(TestContext.Current.CancellationToken);
Assert.Equal(lines[i], receivedLine);
}
}
Expand Down

0 comments on commit f5f775f

Please sign in to comment.