NetworkServerTest cleanup

This commit is contained in:
vis2k 2021-06-16 11:28:49 +08:00
parent ad5eac2016
commit 3debc65ffd
2 changed files with 6 additions and 4 deletions

View File

@ -30,6 +30,12 @@ public virtual void TearDown()
NetworkClient.Shutdown();
NetworkServer.Shutdown();
// some tests might modify NetworkServer.connections without ever
// starting the server.
// NetworkServer.Shutdown() only clears connections if it was started.
// so let's do it manually for proper test cleanup here.
NetworkServer.connections.Clear();
foreach (GameObject go in instantiated)
if (go != null)
GameObject.DestroyImmediate(go);

View File

@ -858,8 +858,6 @@ public void NoExternalConnections_WithConnections()
NetworkServer.connections.Add(2, null);
Assert.That(NetworkServer.NoExternalConnections(), Is.False);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(2));
NetworkServer.connections.Clear();
}
[Test]
@ -873,7 +871,6 @@ public void NoExternalConnections_WithHostOnly()
Assert.That(NetworkServer.NoExternalConnections(), Is.True);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
NetworkServer.connections.Clear();
NetworkServer.RemoveLocalConnection();
}
@ -889,7 +886,6 @@ public void NoExternalConnections_WithHostAndConnection()
Assert.That(NetworkServer.NoExternalConnections(), Is.False);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(2));
NetworkServer.connections.Clear();
NetworkServer.RemoveLocalConnection();
}