NetworkIdentityTests: HostMode isServer/isClient/isLocalPlayer test added

This commit is contained in:
vis2k 2020-02-06 12:42:19 +01:00
parent 09ec344821
commit 85e9a0aa13

View File

@ -122,5 +122,38 @@ public void ServerMode_IsFlags_Test()
NetworkServer.Shutdown(); NetworkServer.Shutdown();
Transport.activeTransport = null; Transport.activeTransport = null;
} }
// check isClient/isServer/isLocalPlayer in host mode
[Test]
public void HostMode_IsFlags_Test()
{
// start the server
Transport.activeTransport = Substitute.For<Transport>();
NetworkServer.Listen(1000);
// start the client
NetworkClient.ConnectHost();
// create a networkidentity+component
GameObject gameObject = new GameObject();
NetworkIdentity identity = gameObject.AddComponent<NetworkIdentity>();
IsClientServerCheckComponent component = gameObject.AddComponent<IsClientServerCheckComponent>();
// spawn it
NetworkServer.Spawn(gameObject);
// OnStartServer should have been called. check the flags.
Assert.That(component.OnStartServer_isClient, Is.EqualTo(true));
Assert.That(component.OnStartServer_isLocalPlayer, Is.EqualTo(false));
Assert.That(component.OnStartServer_isServer, Is.EqualTo(true));
// stop the client
NetworkClient.Shutdown();
NetworkServer.RemoveLocalConnection();
// stop the server
NetworkServer.Shutdown();
Transport.activeTransport = null;
}
} }
} }