diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index 4e3a84179..aad9c0f59 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -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(); + NetworkServer.Listen(1000); + + // start the client + NetworkClient.ConnectHost(); + + // create a networkidentity+component + GameObject gameObject = new GameObject(); + NetworkIdentity identity = gameObject.AddComponent(); + IsClientServerCheckComponent component = gameObject.AddComponent(); + + // 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; + } } }