NetworkIdentityTests: ClearDirtyComponentsDirtyBits

This commit is contained in:
vis2k 2020-03-02 11:06:48 +01:00
parent df430e1bfc
commit eac93e1a27

View File

@ -1003,5 +1003,33 @@ public void ClearObservers()
// clean up
GameObject.DestroyImmediate(gameObject);
}
[Test]
public void ClearDirtyComponentsDirtyBits()
{
// create a networkidentity and add some components
GameObject gameObject = new GameObject();
NetworkIdentity identity = gameObject.AddComponent<NetworkIdentity>();
OnStartClientTestNetworkBehaviour compA = gameObject.AddComponent<OnStartClientTestNetworkBehaviour>();
OnStartClientTestNetworkBehaviour compB = gameObject.AddComponent<OnStartClientTestNetworkBehaviour>();
// set syncintervals so one is always dirty, one is never dirty
compA.syncInterval = 0;
compB.syncInterval = Mathf.Infinity;
// set components dirty bits
compA.SetDirtyBit(0x0001);
compB.SetDirtyBit(0x1001);
Assert.That(compA.IsDirty(), Is.True); // dirty because interval reached and mask != 0
Assert.That(compB.IsDirty(), Is.False); // not dirty because syncinterval not reached
// call identity.ClearDirtyComponentsDirtyBits
identity.ClearDirtyComponentsDirtyBits();
Assert.That(compA.IsDirty(), Is.False); // should be cleared now
Assert.That(compB.IsDirty(), Is.False); // should be untouched
// clean up
GameObject.DestroyImmediate(gameObject);
}
}
}