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
NetworkServer.Listen(1);
NetworkIdentity identity1 = SpawnSceneObject();
NetworkIdentity identity2 = SpawnSceneObject();
// spawn two scene objects
CreateNetworkedAndSpawn(out _, out NetworkIdentity identity1);
CreateNetworkedAndSpawn(out _, out NetworkIdentity identity2);
identity1.sceneId = (ulong)identity1.GetHashCode();
identity2.sceneId = (ulong)identity2.GetHashCode();
// test
NetworkServer.Shutdown();
@ -106,15 +109,5 @@ public void Shutdown_DisablesAllSpawnedPrefabs()
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;
}
}
}