From 3fcc7415b40e13f8232e63c6f943d66eaa2d471d Mon Sep 17 00:00:00 2001 From: James Frowen Date: Mon, 25 Jan 2021 16:04:51 +0000 Subject: [PATCH] Update HostSetup.cs adding virtual methods for test setup --- Assets/Mirror/Tests/Runtime/HostSetup.cs | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Tests/Runtime/HostSetup.cs b/Assets/Mirror/Tests/Runtime/HostSetup.cs index 2871f703d..1e1f40d04 100644 --- a/Assets/Mirror/Tests/Runtime/HostSetup.cs +++ b/Assets/Mirror/Tests/Runtime/HostSetup.cs @@ -1,5 +1,4 @@ using System.Collections; -using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; @@ -14,6 +13,11 @@ public class HostSetup protected GameObject playerGO; protected NetworkIdentity identity; + protected virtual bool AutoAddPlayer => true; + + protected virtual void afterStartHost() { } + protected virtual void beforeStopHost() { } + [UnitySetUp] public IEnumerator SetupHost() { @@ -28,15 +32,30 @@ public IEnumerator SetupHost() manager.playerPrefab = playerGO; manager.autoStartServerBuild = false; + manager.autoCreatePlayer = AutoAddPlayer; + + if (Application.isBatchMode) + { + Application.targetFrameRate = 60; + } yield return null; manager.StartHost(); + + yield return null; + + afterStartHost(); } - [TearDown] - public void ShutdownHost() + + [UnityTearDown] + public IEnumerator ShutdownHost() { + beforeStopHost(); + + yield return null; + Object.DestroyImmediate(playerGO); manager.StopHost(); Object.DestroyImmediate(networkManagerGo);