NetworkServerTest: GetNetworkIdentity

This commit is contained in:
vis2k 2020-02-25 22:25:47 +01:00
parent 67a2a85cb9
commit 5cdf02b258

View File

@ -821,6 +821,34 @@ public void SendToClientOfPlayer()
GameObject.DestroyImmediate(identity.gameObject); GameObject.DestroyImmediate(identity.gameObject);
} }
[Test]
public void GetNetworkIdentity()
{
// create a GameObject with NetworkIdentity
GameObject go = new GameObject();
NetworkIdentity identity = go.AddComponent<NetworkIdentity>();
// GetNetworkIdentity
bool result = NetworkServer.GetNetworkIdentity(go, out NetworkIdentity value);
Assert.That(result, Is.True);
Assert.That(value, Is.EqualTo(identity));
// create a GameObject without NetworkIdentity
GameObject goWithout = new GameObject();
// GetNetworkIdentity for GO without identity
// (error log is expected)
LogAssert.ignoreFailingMessages = true;
result = NetworkServer.GetNetworkIdentity(goWithout, out NetworkIdentity valueNull);
Assert.That(result, Is.False);
Assert.That(valueNull, Is.Null);
LogAssert.ignoreFailingMessages = false;
// clean up
GameObject.DestroyImmediate(go);
GameObject.DestroyImmediate(goWithout);
}
[Test] [Test]
public void ShutdownCleanupTest() public void ShutdownCleanupTest()
{ {