Tests simplified

This commit is contained in:
vis2k 2021-08-11 14:22:51 +08:00
parent 2328747b33
commit 8b42915429

View File

@ -91,8 +91,11 @@ public void Shutdown_DisablesAllSpawnedPrefabs()
// setup // setup
NetworkServer.Listen(1); NetworkServer.Listen(1);
NetworkIdentity identity1 = SpawnSceneObject(); // spawn two scene objects
NetworkIdentity identity2 = SpawnSceneObject(); CreateNetworkedAndSpawn(out _, out NetworkIdentity identity1);
CreateNetworkedAndSpawn(out _, out NetworkIdentity identity2);
identity1.sceneId = (ulong)identity1.GetHashCode();
identity2.sceneId = (ulong)identity2.GetHashCode();
// test // test
NetworkServer.Shutdown(); NetworkServer.Shutdown();
@ -106,15 +109,5 @@ public void Shutdown_DisablesAllSpawnedPrefabs()
Assert.That(NetworkIdentity.spawned, Is.Empty); Assert.That(NetworkIdentity.spawned, Is.Empty);
} }
NetworkIdentity SpawnSceneObject()
{
CreateNetworked(out GameObject obj, out NetworkIdentity identity);
if (identity.sceneId == 0) { identity.sceneId = (ulong)obj.GetHashCode(); }
NetworkServer.Spawn(obj);
Assert.IsTrue(NetworkIdentity.spawned.ContainsValue(identity));
return identity;
}
} }
} }