diff --git a/test/tcp/FixTcp.SendAndReceive.cs b/test/tcp/FixTcp.SendAndReceive.cs index 553ec12..293b6ea 100644 --- a/test/tcp/FixTcp.SendAndReceive.cs +++ b/test/tcp/FixTcp.SendAndReceive.cs @@ -55,7 +55,7 @@ void Server() Assert.False(isModify); } - server.To.Open(host).Wait(); + server.To.Open(host).Wait(); Thread.Sleep(millisecondsTimeout: 20); { @@ -67,10 +67,12 @@ void Server() } const int maxConnection = 20; + List actions = new(); for (int i = 0; i < maxConnection; i++) { - Client(server.Host); + Client(server.Host, out Action action); + actions.Add(action); } Thread.Sleep(1000); @@ -78,9 +80,14 @@ void Server() Assert.Equal(maxConnection, server.Clients.Length); Assert.Equal(maxConnection, allDataReceived); Assert.Equal(maxConnection, allEventReceived); + + foreach (var action in actions) + { + action(); + } } - void Client(Host host) + void Client(Host host, out Action check) { TCP.Client client = new(); @@ -110,12 +117,12 @@ void Client(Host host) Assert.Empty(eventReceived.data); // event } - client.To.Open(host).Wait(); - + client.To.Open(host).Wait(); + Thread.Sleep(10); client.To.Data(dataSent); client.To.Event(eventSent.name, eventSent.data); - Thread.Sleep(millisecondsTimeout: 25); + check = () => { Assert.True(client.IsOpened); Assert.True(isModify); @@ -131,7 +138,7 @@ void Client(Host host) Assert.Equal(dataSent, dataReceived); // data Assert.Equal(eventSent.name, eventReceived.name); // event Assert.Equal(eventSent.data, eventReceived.data); // event - } + }; } } } \ No newline at end of file