NetworkServerTest: reuse CreateLocalConnectionPair

This commit is contained in:
vis2k 2021-06-15 16:49:44 +08:00
parent 68c72a7d54
commit bf7250c096

View File

@ -762,9 +762,8 @@ public void HideForConnection()
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
// setup connections
LocalConnectionToClient connectionToClient = new LocalConnectionToClient();
LocalConnectionToServer connectionToServer = new LocalConnectionToServer();
connectionToClient.connectionToServer = new LocalConnectionToServer();
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient,
out LocalConnectionToServer connectionToServer);
// setup NetworkServer/Client connections so messages are handled
NetworkClient.connection = connectionToServer;
@ -772,7 +771,6 @@ public void HideForConnection()
// required for ShowForConnection
connectionToClient.isReady = true;
connectionToClient.connectionToServer = new LocalConnectionToServer();
// set a client handler
int called = 0;
@ -946,10 +944,7 @@ public void NoExternalConnectionsTest_WithConnections()
[Test]
public void NoExternalConnectionsTest_WithHostOnly()
{
LocalConnectionToServer connectionToServer = new LocalConnectionToServer();
LocalConnectionToClient connectionToClient = new LocalConnectionToClient();
connectionToServer.connectionToClient = connectionToClient;
connectionToClient.connectionToServer = connectionToServer;
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
NetworkServer.SetLocalConnection(connectionToClient);
NetworkServer.connections.Add(0, connectionToClient);