From a700d7afc3d134b0f9d6a3a4e6a8b55e5db3c850 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Sat, 2 May 2020 16:14:38 +0100 Subject: [PATCH] Fixing runtime tests (#1833) * adding assetId to prefab * making sure NetworkManager is shutdown * removing host set up for test that doesn't need it * using OneTimeTearDown * fixing performance test --- .../Runtime/ULocalConnectionPerformance.cs | 14 +++++++++++++- Assets/Mirror/Tests/Runtime/HostSetup.cs | 1 + Assets/Mirror/Tests/Runtime/NetworkManagerTests.cs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs b/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs index 70be227f1..057df7225 100644 --- a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs +++ b/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs @@ -13,7 +13,9 @@ class NetworkManagerTest : NetworkManager public override void Awake() { transport = gameObject.AddComponent(); - playerPrefab = new GameObject("testPlayerPrefab", typeof(NetworkIdentity)); + playerPrefab = new GameObject(); + NetworkIdentity identity = playerPrefab.AddComponent(); + identity.assetId = System.Guid.NewGuid(); base.Awake(); } public override void OnDestroy() @@ -45,6 +47,16 @@ IEnumerator Disconnect() yield return null; GameObject.Destroy(manager.gameObject); } + [OneTimeTearDown] + public void OneTimeTearDown() + { + if (NetworkManager.singleton != null) + { + GameObject go = NetworkManager.singleton.gameObject; + NetworkManager.Shutdown(); + GameObject.DestroyImmediate(go); + } + } [UnityTest] public IEnumerator ConnectAndDisconnectWorks() diff --git a/Assets/Mirror/Tests/Runtime/HostSetup.cs b/Assets/Mirror/Tests/Runtime/HostSetup.cs index 9bb4dd34c..a72cb660b 100644 --- a/Assets/Mirror/Tests/Runtime/HostSetup.cs +++ b/Assets/Mirror/Tests/Runtime/HostSetup.cs @@ -24,6 +24,7 @@ public IEnumerator SetupHost() playerGO = new GameObject(); identity = playerGO.AddComponent(); + identity.assetId = System.Guid.NewGuid(); manager.playerPrefab = playerGO; manager.startOnHeadless = false; diff --git a/Assets/Mirror/Tests/Runtime/NetworkManagerTests.cs b/Assets/Mirror/Tests/Runtime/NetworkManagerTests.cs index 94834639a..c1cf3e2f1 100644 --- a/Assets/Mirror/Tests/Runtime/NetworkManagerTests.cs +++ b/Assets/Mirror/Tests/Runtime/NetworkManagerTests.cs @@ -5,7 +5,7 @@ namespace Mirror.Tests.Runtime { - public class NetworkManagerTests : HostSetup + public class NetworkManagerTests { Scene activeScene;