GetSyncVarNetworkIdentityOnClient Test: use CreateNetworkedAndSpawn instead of manually adding to spawned

This commit is contained in:
vis2k 2021-08-10 18:45:07 +08:00
parent 4591bde5e3
commit 3d350f3320

View File

@ -828,19 +828,19 @@ public void GetSyncVarNetworkIdentityOnServerNull()
[Test]
public void GetSyncVarNetworkIdentityOnClient()
{
// start server & connect client because we need spawn functions
NetworkServer.Listen(1);
ConnectClientBlockingAuthenticatedAndReady(out _);
CreateNetworked(out GameObject _, out NetworkIdentity identity, out NetworkBehaviourGetSyncVarNetworkIdentityComponent comp);
// are we on client and not on server?
identity.isClient = true;
Assert.That(identity.isServer, Is.False);
// create a syncable GameObject
CreateNetworked(out GameObject _, out NetworkIdentity ni);
ni.netId = 43;
// register in spawned dict because clients should look it up via
// netId
NetworkIdentity.spawned[ni.netId] = ni;
// create a spawned, syncable GameObject
// (client tries to look up via netid, so needs to be spawned)
CreateNetworkedAndSpawn(out GameObject _, out NetworkIdentity ni);
// assign ONLY netId in the component. assume that GameObject was
// assigned earlier but client walked so far out of range that it