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
This commit is contained in:
James Frowen 2020-05-02 16:14:38 +01:00 committed by GitHub
parent 2b5ad08260
commit a700d7afc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -13,7 +13,9 @@ class NetworkManagerTest : NetworkManager
public override void Awake()
{
transport = gameObject.AddComponent<MemoryTransport>();
playerPrefab = new GameObject("testPlayerPrefab", typeof(NetworkIdentity));
playerPrefab = new GameObject();
NetworkIdentity identity = playerPrefab.AddComponent<NetworkIdentity>();
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()

View File

@ -24,6 +24,7 @@ public IEnumerator SetupHost()
playerGO = new GameObject();
identity = playerGO.AddComponent<NetworkIdentity>();
identity.assetId = System.Guid.NewGuid();
manager.playerPrefab = playerGO;
manager.startOnHeadless = false;

View File

@ -5,7 +5,7 @@
namespace Mirror.Tests.Runtime
{
public class NetworkManagerTests : HostSetup
public class NetworkManagerTests
{
Scene activeScene;