Tests simplified

This commit is contained in:
vis2k 2021-08-11 14:13:59 +08:00
parent ff4bc267e0
commit 2fff5ef02b

View File

@ -14,23 +14,20 @@ public override IEnumerator UnitySetUp()
{ {
yield return base.UnitySetUp(); yield return base.UnitySetUp();
// start server and wait 1 frame // start server & client and wait 1 frame
NetworkServer.Listen(1); NetworkServer.Listen(1);
ConnectHostClientBlockingAuthenticatedAndReady();
yield return null; yield return null;
} }
[UnityTest] [UnityTest]
public IEnumerator DestroyPlayerForConnectionTest() public IEnumerator DestroyPlayerForConnectionTest()
{ {
CreateNetworked(out GameObject player, out _); // create spawned player
NetworkConnectionToClient conn = new NetworkConnectionToClient(1); CreateNetworkedAndSpawnPlayer(out GameObject player, out _, NetworkServer.localConnection);
// add player, wait 1 frame to spawn
NetworkServer.AddPlayerForConnection(conn, player);
yield return null;
// destroy player for connection, wait 1 frame to unspawn and destroy // destroy player for connection, wait 1 frame to unspawn and destroy
NetworkServer.DestroyPlayerForConnection(conn); NetworkServer.DestroyPlayerForConnection(NetworkServer.localConnection);
yield return null; yield return null;
Assert.That(player == null, "Player should be destroyed with DestroyPlayerForConnection"); Assert.That(player == null, "Player should be destroyed with DestroyPlayerForConnection");