Update HostSetup.cs

adding virtual methods for test setup
This commit is contained in:
James Frowen 2021-01-25 16:04:51 +00:00 committed by GitHub
parent 7bcf957c23
commit 3fcc7415b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);