NetworkIdentityTests: ClearObservers

This commit is contained in:
vis2k 2020-03-01 11:54:02 +01:00
parent d9036a6a79
commit 90cece63dc

View File

@ -932,5 +932,27 @@ public void OnNetworkDestroy()
// clean up
GameObject.DestroyImmediate(gameObject);
}
[Test]
public void ClearObservers()
{
// create a networkidentity
GameObject gameObject = new GameObject();
NetworkIdentity identity = gameObject.AddComponent<NetworkIdentity>();
// call OnStartServer so that observers dict is created
identity.OnStartServer();
// add some observers
identity.observers[42] = new NetworkConnectionToClient(42);
identity.observers[43] = new NetworkConnectionToClient(43);
// call ClearObservers
identity.ClearObservers();
Assert.That(identity.observers.Count, Is.EqualTo(0));
// clean up
GameObject.DestroyImmediate(gameObject);
}
}
}