mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkIdentityTests: HostMode isServer/isClient/isLocalPlayer test added
This commit is contained in:
parent
09ec344821
commit
85e9a0aa13
@ -122,5 +122,38 @@ public void ServerMode_IsFlags_Test()
|
||||
NetworkServer.Shutdown();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user