Skip to content

Commit 32b62f6

Browse files
committed
test: 更新单元测试
1 parent f65271a commit 32b62f6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/UnitTest/Services/TcpSocketFactoryTest.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public async Task ReceiveAsync_InvalidOperationException()
195195

196196
var client = CreateClient();
197197

198-
// 未连接
198+
//未连接
199199
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.ReceiveAsync());
200200
Assert.NotNull(ex);
201201

@@ -211,13 +211,15 @@ public async Task ReceiveAsync_InvalidOperationException()
211211
ex = null;
212212
ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.ReceiveAsync());
213213

214-
//client.Close();
215-
//client.IsAutoReceive = false;
216-
//await client.ConnectAsync("localhost", port);
217-
//var data = new ReadOnlyMemory<byte>([1, 2, 3, 4, 5]);
218-
//await client.SendAsync(data);
219-
//var payload = await client.ReceiveAsync();
220-
//Assert.Equal(payload.ToArray(), [1, 2, 3, 4, 5]);
214+
client.Close();
215+
client.IsAutoReceive = false;
216+
var connected = await client.ConnectAsync("localhost", port);
217+
Assert.True(connected);
218+
219+
var data = new ReadOnlyMemory<byte>([1, 2, 3, 4, 5]);
220+
await client.SendAsync(data);
221+
var payload = await client.ReceiveAsync();
222+
Assert.Equal(payload.ToArray(), [1, 2, 3, 4, 5]);
221223
}
222224

223225
[Fact]

0 commit comments

Comments
 (0)