Skip to content

Commit cf99565

Browse files
committed
test: 更新单元测试
1 parent b8f2c6e commit cf99565

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/UnitTest/Services/TcpSocketFactoryTest.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ public async Task ReceiveAsync_Ok()
247247
// 未设置数据处理器未开启自动接收时,调用 ReceiveAsync 方法获取数据
248248
// 需要自己处理粘包分包和业务问题
249249
var payload = await client.ReceiveAsync();
250-
Assert.Equal(payload.ToArray(), [1, 2, 3, 4, 5]);
250+
Assert.Equal([1, 2, 3, 4, 5], payload.ToArray());
251251

252252
// 由于服务器端模拟了拆包发送第二段数据,所以这里可以再次调用 ReceiveAsync 方法获取第二段数据
253253
payload = await client.ReceiveAsync();
254-
Assert.Equal(payload.ToArray(), [3, 4]);
254+
Assert.Equal([3, 4], payload.ToArray());
255255
}
256256

257257
[Fact]
@@ -296,7 +296,7 @@ public async Task ReceiveAsync_Error()
296296
await client.SendAsync(data);
297297

298298
await tcs.Task;
299-
Assert.Equal(buffer.ToArray(), [1, 2, 3, 4, 5]);
299+
Assert.Equal([1, 2, 3, 4, 5], buffer.ToArray());
300300

301301
// 关闭连接
302302
StopTcpServer(server);
@@ -336,7 +336,7 @@ public async Task FixLengthDataPackageHandler_Ok()
336336
Assert.True(result);
337337

338338
await tcs.Task;
339-
Assert.Equal(receivedBuffer.ToArray(), [1, 2, 3, 4, 5, 3, 4]);
339+
Assert.Equal([1, 2, 3, 4, 5, 3, 4], receivedBuffer.ToArray());
340340

341341
// 关闭连接
342342
await client.CloseAsync();
@@ -378,7 +378,7 @@ public async Task FixLengthDataPackageHandler_Sticky()
378378
await tcs.Task;
379379

380380
// 验证接收到的数据
381-
Assert.Equal(receivedBuffer.ToArray(), [1, 2, 3, 4, 5, 3, 4]);
381+
Assert.Equal([1, 2, 3, 4, 5, 3, 4], receivedBuffer.ToArray());
382382

383383
// 重置接收缓冲区
384384
receivedBuffer = new byte[1024];
@@ -388,12 +388,12 @@ public async Task FixLengthDataPackageHandler_Sticky()
388388
await tcs.Task;
389389

390390
// 验证第二次收到的数据
391-
Assert.Equal(receivedBuffer.ToArray(), [2, 2, 3, 4, 5, 6, 7]);
391+
Assert.Equal([2, 2, 3, 4, 5, 6, 7], receivedBuffer.ToArray());
392392
tcs = new TaskCompletionSource();
393393
await tcs.Task;
394394

395395
// 验证第三次收到的数据
396-
Assert.Equal(receivedBuffer.ToArray(), [3, 2, 3, 4, 5, 6, 7]);
396+
Assert.Equal([3, 2, 3, 4, 5, 6, 7], receivedBuffer.ToArray());
397397

398398
// 关闭连接
399399
await client.CloseAsync();
@@ -434,15 +434,15 @@ public async Task DelimiterDataPackageHandler_Ok()
434434
await tcs.Task;
435435

436436
// 验证接收到的数据
437-
Assert.Equal(receivedBuffer.ToArray(), [1, 2, 3, 4, 5, 13, 10]);
437+
Assert.Equal([1, 2, 3, 4, 5, 13, 10], receivedBuffer.ToArray());
438438

439439
// 等待第二次数据
440440
receivedBuffer = new byte[1024];
441441
tcs = new TaskCompletionSource();
442442
await tcs.Task;
443443

444444
// 验证接收到的数据
445-
Assert.Equal(receivedBuffer.ToArray(), [5, 6, 13, 10]);
445+
Assert.Equal([5, 6, 13, 10], receivedBuffer.ToArray());
446446

447447
// 关闭连接
448448
await client.CloseAsync();
@@ -486,8 +486,8 @@ public async Task TryConvertTo_Ok()
486486
await tcs.Task;
487487

488488
Assert.NotNull(entity);
489-
Assert.Equal(entity.Header, [1, 2, 3, 4, 5]);
490-
Assert.Equal(entity.Body, [3, 4]);
489+
Assert.Equal([1, 2, 3, 4, 5], entity.Header);
490+
Assert.Equal([3, 4], entity.Body);
491491

492492
// 测试异常流程
493493
var adapter2 = new DataPackageAdapter();

0 commit comments

Comments
 (0)