Skip to content

Commit 2f77b96

Browse files
committed
test: 增加连接超时单元测试
1 parent 8b8a0b7 commit 2f77b96

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/UnitTest/Services/TcpSocketFactoryTest.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public void GetOrCreate_Ok()
4444
factory.Dispose();
4545
}
4646

47+
[Fact]
48+
public async Task ConnectAsync_Timeout()
49+
{
50+
var client = CreateClient();
51+
client.ConnectTimeout = 1000;
52+
53+
var connect = await client.ConnectAsync("localhost", 9999);
54+
Assert.False(connect);
55+
}
56+
4757
[Fact]
4858
public async Task ConnectAsync_Cancel()
4959
{
@@ -136,7 +146,7 @@ public async Task ReceiveAsync_Error()
136146
var port = 8882;
137147
var server = StartTcpServer(port, MockSplitPackageAsync);
138148

139-
Assert.Equal(1024 * 10, client.ReceiveBufferSize);
149+
Assert.Equal(1024 * 64, client.ReceiveBufferSize);
140150

141151
client.ReceiveBufferSize = 1024 * 20;
142152
Assert.Equal(1024 * 20, client.ReceiveBufferSize);

0 commit comments

Comments
 (0)