NetworkServerTest: ReadyMessageSetsClientReady cleanup

This commit is contained in:
vis2k 2021-06-15 17:06:51 +08:00
parent 092ff4538a
commit 26e18d7e87

View File

@ -427,7 +427,6 @@ public void ReadyMessageSetsClientReady()
{ {
// listen // listen
NetworkServer.Listen(1); NetworkServer.Listen(1);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
// add connection // add connection
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _); CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
@ -437,17 +436,12 @@ public void ReadyMessageSetsClientReady()
connectionToClient.isAuthenticated = true; connectionToClient.isAuthenticated = true;
// serialize a ready message into an arraysegment // serialize a ready message into an arraysegment
ReadyMessage message = new ReadyMessage(); byte[] message = MessagePackingTest.PackToByteArray(new ReadyMessage());
NetworkWriter writer = new NetworkWriter();
MessagePacking.Pack(message, writer);
ArraySegment<byte> segment = writer.ToArraySegment();
// call transport.OnDataReceived with the message // call transport.OnDataReceived with the message
// -> calls NetworkServer.OnClientReadyMessage // -> calls NetworkServer.OnClientReadyMessage
// -> calls SetClientReady(conn) // -> calls SetClientReady(conn)
transport.OnServerDataReceived.Invoke(0, segment, 0); transport.OnServerDataReceived.Invoke(0, new ArraySegment<byte>(message), 0);
// ready?
Assert.That(connectionToClient.isReady, Is.True); Assert.That(connectionToClient.isReady, Is.True);
} }