Tests: IsDirty

This commit is contained in:
vis2k 2021-09-16 14:40:30 +08:00
parent 7828f25875
commit 58ef1faaf9

View File

@ -66,6 +66,25 @@ public void AnySyncObjectDirty()
Assert.That(comp.AnySyncObjectDirty(), Is.True);
}
[Test]
public void IsDirty()
{
CreateNetworked(out GameObject _, out NetworkIdentity _, out NetworkBehaviourWithSyncVarsAndCollections comp);
// not dirty by default
Assert.That(comp.IsDirty(), Is.False);
// changing a [SyncVar] should set it dirty
++comp.health;
Assert.That(comp.IsDirty(), Is.True);
comp.ClearAllDirtyBits();
// changing a SyncCollection should set it dirty
comp.list.Add(42);
Assert.That(comp.IsDirty(), Is.True);
comp.ClearAllDirtyBits();
}
[Test]
public void ClearAllDirtyBitsClearsSyncVarDirtyBits()
{