From 76ebb86d6d3709570d934ba59d58b31f359d4d7d Mon Sep 17 00:00:00 2001 From: vis2k Date: Fri, 17 Sep 2021 14:53:02 +0800 Subject: [PATCH] Tests: don't need to inherit from SyncList anymore --- .../Mirror/Tests/Editor/SyncDictionaryTest.cs | 22 +++++++++---------- Assets/Mirror/Tests/Editor/SyncSetTest.cs | 18 +++++++-------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Assets/Mirror/Tests/Editor/SyncDictionaryTest.cs b/Assets/Mirror/Tests/Editor/SyncDictionaryTest.cs index 4075a1a4b..e3ff7a5e8 100644 --- a/Assets/Mirror/Tests/Editor/SyncDictionaryTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncDictionaryTest.cs @@ -7,10 +7,8 @@ namespace Mirror.Tests [TestFixture] public class SyncDictionaryTest { - public class SyncDictionaryIntString : SyncDictionary {} - - SyncDictionaryIntString serverSyncDictionary; - SyncDictionaryIntString clientSyncDictionary; + SyncDictionary serverSyncDictionary; + SyncDictionary clientSyncDictionary; void SerializeAllTo(T fromList, T toList) where T : SyncObject { @@ -32,8 +30,8 @@ void SerializeDeltaTo(T fromList, T toList) where T : SyncObject [SetUp] public void SetUp() { - serverSyncDictionary = new SyncDictionaryIntString(); - clientSyncDictionary = new SyncDictionaryIntString(); + serverSyncDictionary = new SyncDictionary(); + clientSyncDictionary = new SyncDictionary(); // add some data to the list serverSyncDictionary.Add(0, "Hello"); @@ -69,7 +67,7 @@ public void TestClear() { serverSyncDictionary.Clear(); SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); - Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionaryIntString())); + Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionary())); } [Test] @@ -156,7 +154,7 @@ public void CallbackTest() { called = true; - Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_ADD)); + Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); Assert.That(index, Is.EqualTo(3)); Assert.That(item, Is.EqualTo("yay")); Assert.That(clientSyncDictionary[index], Is.EqualTo("yay")); @@ -175,7 +173,7 @@ public void ServerCallbackTest() { called = true; - Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_ADD)); + Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); Assert.That(index, Is.EqualTo(3)); Assert.That(item, Is.EqualTo("yay")); Assert.That(serverSyncDictionary[index], Is.EqualTo("yay")); @@ -191,7 +189,7 @@ public void CallbackRemoveTest() clientSyncDictionary.Callback += (op, key, item) => { called = true; - Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_REMOVE)); + Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_REMOVE)); Assert.That(item, Is.EqualTo("World")); }; serverSyncDictionary.Remove(1); @@ -294,8 +292,8 @@ public void ObjectCanBeReusedAfterReset() clientSyncDictionary.Reset(); // make old client the host - SyncDictionaryIntString hostList = clientSyncDictionary; - SyncDictionaryIntString clientList2 = new SyncDictionaryIntString(); + SyncDictionary hostList = clientSyncDictionary; + SyncDictionary clientList2 = new SyncDictionary(); Assert.That(hostList.IsReadOnly, Is.False); diff --git a/Assets/Mirror/Tests/Editor/SyncSetTest.cs b/Assets/Mirror/Tests/Editor/SyncSetTest.cs index 23f648569..fe80269be 100644 --- a/Assets/Mirror/Tests/Editor/SyncSetTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncSetTest.cs @@ -7,10 +7,8 @@ namespace Mirror.Tests [TestFixture] public class SyncSetTest { - public class SyncSetString : SyncHashSet {} - - SyncSetString serverSyncSet; - SyncSetString clientSyncSet; + SyncHashSet serverSyncSet; + SyncHashSet clientSyncSet; void SerializeAllTo(T fromList, T toList) where T : SyncObject { @@ -32,8 +30,8 @@ void SerializeDeltaTo(T fromList, T toList) where T : SyncObject [SetUp] public void SetUp() { - serverSyncSet = new SyncSetString(); - clientSyncSet = new SyncSetString(); + serverSyncSet = new SyncHashSet(); + clientSyncSet = new SyncHashSet(); // add some data to the list serverSyncSet.Add("Hello"); @@ -99,7 +97,7 @@ public void CallbackTest() { called = true; - Assert.That(op, Is.EqualTo(SyncSetString.Operation.OP_ADD)); + Assert.That(op, Is.EqualTo(SyncHashSet.Operation.OP_ADD)); Assert.That(item, Is.EqualTo("yay")); }; @@ -118,7 +116,7 @@ public void CallbackRemoveTest() { called = true; - Assert.That(op, Is.EqualTo(SyncSetString.Operation.OP_REMOVE)); + Assert.That(op, Is.EqualTo(SyncHashSet.Operation.OP_REMOVE)); Assert.That(item, Is.EqualTo("World")); }; serverSyncSet.Remove("World"); @@ -263,8 +261,8 @@ public void ObjectCanBeReusedAfterReset() clientSyncSet.Reset(); // make old client the host - SyncSetString hostList = clientSyncSet; - SyncSetString clientList2 = new SyncSetString(); + SyncHashSet hostList = clientSyncSet; + SyncHashSet clientList2 = new SyncHashSet(); Assert.That(hostList.IsReadOnly, Is.False);