Skip to content

Commit

Permalink
fix. FixTcp.OpenAndClose. (new impl.)
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jun 30, 2024
1 parent d7ac129 commit 2eebf14
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/tcp/FixTcp.SendAndReceive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Server()
Assert.False(isModify);
}

server.To.Open(host).Wait();
server.To.Open(host).Wait();

Thread.Sleep(millisecondsTimeout: 20);
{
Expand All @@ -67,20 +67,27 @@ void Server()
}

const int maxConnection = 20;
List<Action> actions = new();

for (int i = 0; i < maxConnection; i++)
{
Client(server.Host);
Client(server.Host, out Action action);
actions.Add(action);
}

Thread.Sleep(1000);

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();

Expand Down Expand Up @@ -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);
Expand All @@ -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
}
};
}
}
}

0 comments on commit 2eebf14

Please sign in to comment.