From 8961eb2ec69c8aac03d6bf2d24efe5f9b252e908 Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 20 May 2021 15:56:54 +0800 Subject: [PATCH] SyncVarTest: reuse CreateNetworked --- Assets/Mirror/Tests/Editor/SyncVarTest.cs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Assets/Mirror/Tests/Editor/SyncVarTest.cs b/Assets/Mirror/Tests/Editor/SyncVarTest.cs index f9c3455e0..4fc5f8605 100644 --- a/Assets/Mirror/Tests/Editor/SyncVarTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncVarTest.cs @@ -41,9 +41,7 @@ public class SyncVarTest : SyncVarTestBase [Test] public void TestSettingStruct() { - GameObject gameObject = new GameObject(); - - MockPlayer player = gameObject.AddComponent(); + CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player); // synchronize immediately player.syncInterval = 0f; @@ -69,9 +67,7 @@ public void TestSettingStruct() [Test] public void TestSyncIntervalAndClearDirtyComponents() { - GameObject gameObject = new GameObject(); - - MockPlayer player = gameObject.AddComponent(); + CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player); player.lastSyncTime = Time.time; // synchronize immediately player.syncInterval = 1f; @@ -97,9 +93,7 @@ public void TestSyncIntervalAndClearDirtyComponents() [Test] public void TestSyncIntervalAndClearAllComponents() { - GameObject gameObject = new GameObject(); - - MockPlayer player = gameObject.AddComponent(); + CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player); player.lastSyncTime = Time.time; // synchronize immediately player.syncInterval = 1f; @@ -126,9 +120,7 @@ public void TestSyncIntervalAndClearAllComponents() public void TestSynchronizingObjects() { // set up a "server" object - GameObject gameObject1 = new GameObject(); - NetworkIdentity identity1 = gameObject1.AddComponent(); - MockPlayer player1 = gameObject1.AddComponent(); + CreateNetworked(out GameObject gameObject1, out NetworkIdentity identity1, out MockPlayer player1); MockPlayer.Guild myGuild = new MockPlayer.Guild { name = "Back street boys" @@ -142,9 +134,7 @@ public void TestSynchronizingObjects() identity1.OnSerializeAllSafely(true, ownerWriter, out int ownerWritten, observersWriter, out int observersWritten); // set up a "client" object - GameObject gameObject2 = new GameObject(); - NetworkIdentity identity2 = gameObject2.AddComponent(); - MockPlayer player2 = gameObject2.AddComponent(); + CreateNetworked(out GameObject gameObject2, out NetworkIdentity identity2, out MockPlayer player2); // apply all the data from the server object NetworkReader reader = new NetworkReader(ownerWriter.ToArray());