From cc22fabe1d9e1d2191363e37dc323fb65c5ef640 Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 16 Sep 2021 14:36:38 +0800 Subject: [PATCH] syntax --- .../Editor/NetworkBehaviourDirtyBitsTests.cs | 83 +++++++++---------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourDirtyBitsTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourDirtyBitsTests.cs index c1b9d3b92..6cb83b824 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourDirtyBitsTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourDirtyBitsTests.cs @@ -13,48 +13,6 @@ class NetworkBehaviourWithSyncCollections : NetworkBehaviour public class NetworkBehaviourDirtyBitsTests : MirrorEditModeTest { - [Test] - public void ClearAllDirtyBitsClearsSyncVarDirtyBits() - { - CreateNetworked(out GameObject _, out NetworkIdentity _, out EmptyBehaviour emptyBehaviour); - - // set syncinterval so dirtybit works fine - emptyBehaviour.syncInterval = 0; - Assert.That(emptyBehaviour.IsDirty(), Is.False); - - // set one syncvar dirty bit - emptyBehaviour.SetDirtyBit(1); - Assert.That(emptyBehaviour.IsDirty(), Is.True); - - // clear it - emptyBehaviour.ClearAllDirtyBits(); - Assert.That(emptyBehaviour.IsDirty(), Is.False); - } - - [Test] - public void ClearAllDirtyBitsClearsSyncObjectsDirtyBits() - { - CreateNetworked(out GameObject _, out NetworkIdentity _, out NetworkBehaviourInitSyncObjectExposed comp); - - // set syncinterval so dirtybit works fine - comp.syncInterval = 0; - Assert.That(comp.IsDirty(), Is.False); - - // create a synclist and dirty it - SyncList obj = new SyncList(); - obj.Add(42); - Assert.That(obj.IsDirty, Is.True); - - // add it - comp.InitSyncObjectExposed(obj); - Assert.That(comp.IsDirty, Is.True); - - // clear bits should clear synclist bits too - comp.ClearAllDirtyBits(); - Assert.That(comp.IsDirty, Is.False); - Assert.That(obj.IsDirty, Is.False); - } - [Test] public void DirtyObjectBits() { @@ -102,6 +60,47 @@ public void AnySyncObjectDirty() comp.list.Flush(); Assert.That(comp.AnySyncObjectDirty(), Is.True); } + [Test] + public void ClearAllDirtyBitsClearsSyncVarDirtyBits() + { + CreateNetworked(out GameObject _, out NetworkIdentity _, out EmptyBehaviour emptyBehaviour); + + // set syncinterval so dirtybit works fine + emptyBehaviour.syncInterval = 0; + Assert.That(emptyBehaviour.IsDirty(), Is.False); + + // set one syncvar dirty bit + emptyBehaviour.SetDirtyBit(1); + Assert.That(emptyBehaviour.IsDirty(), Is.True); + + // clear it + emptyBehaviour.ClearAllDirtyBits(); + Assert.That(emptyBehaviour.IsDirty(), Is.False); + } + + [Test] + public void ClearAllDirtyBitsClearsSyncObjectsDirtyBits() + { + CreateNetworked(out GameObject _, out NetworkIdentity _, out NetworkBehaviourInitSyncObjectExposed comp); + + // set syncinterval so dirtybit works fine + comp.syncInterval = 0; + Assert.That(comp.IsDirty(), Is.False); + + // create a synclist and dirty it + SyncList obj = new SyncList(); + obj.Add(42); + Assert.That(obj.IsDirty, Is.True); + + // add it + comp.InitSyncObjectExposed(obj); + Assert.That(comp.IsDirty, Is.True); + + // clear bits should clear synclist bits too + comp.ClearAllDirtyBits(); + Assert.That(comp.IsDirty, Is.False); + Assert.That(obj.IsDirty, Is.False); + } } // hook tests can only be ran when inheriting from NetworkBehaviour