mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Tests: merge HostSetup into the only class that inherits from it
This commit is contained in:
parent
87478178e9
commit
4925f1397a
@ -5,8 +5,65 @@
|
||||
|
||||
namespace Mirror.Tests.Runtime
|
||||
{
|
||||
public class ClientSceneTest_LocalPlayer_AsHost : HostSetup
|
||||
public class ClientSceneTest_LocalPlayer_AsHost : MirrorPlayModeTest
|
||||
{
|
||||
protected GameObject networkManagerGo;
|
||||
protected NetworkManager manager;
|
||||
|
||||
protected GameObject playerGO;
|
||||
protected NetworkIdentity identity;
|
||||
|
||||
protected virtual bool AutoAddPlayer => true;
|
||||
|
||||
protected virtual void afterStartHost() {}
|
||||
protected virtual void beforeStopHost() {}
|
||||
|
||||
[UnitySetUp]
|
||||
public override IEnumerator UnitySetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
networkManagerGo = transport.gameObject;
|
||||
manager = networkManagerGo.AddComponent<NetworkManager>();
|
||||
Transport.activeTransport = transport;
|
||||
|
||||
// create a tracked prefab (not spawned)
|
||||
CreateGameObject(out playerGO);
|
||||
identity = playerGO.AddComponent<NetworkIdentity>();
|
||||
identity.assetId = System.Guid.NewGuid();
|
||||
|
||||
manager.playerPrefab = playerGO;
|
||||
manager.autoStartServerBuild = false;
|
||||
manager.autoCreatePlayer = AutoAddPlayer;
|
||||
|
||||
if (Application.isBatchMode)
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
manager.StartHost();
|
||||
|
||||
yield return null;
|
||||
|
||||
afterStartHost();
|
||||
}
|
||||
|
||||
[UnityTearDown]
|
||||
public override IEnumerator UnityTearDown()
|
||||
{
|
||||
beforeStopHost();
|
||||
|
||||
yield return null;
|
||||
|
||||
// needed for stophost
|
||||
Transport.activeTransport = transport;
|
||||
manager.StopHost();
|
||||
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator LocalPlayerIsSetToNullAfterNetworkDestroy()
|
||||
{
|
||||
|
@ -1,66 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Mirror.Tests.Runtime
|
||||
{
|
||||
public class HostSetup : MirrorPlayModeTest
|
||||
{
|
||||
protected GameObject networkManagerGo;
|
||||
protected NetworkManager manager;
|
||||
|
||||
protected GameObject playerGO;
|
||||
protected NetworkIdentity identity;
|
||||
|
||||
protected virtual bool AutoAddPlayer => true;
|
||||
|
||||
protected virtual void afterStartHost() {}
|
||||
protected virtual void beforeStopHost() {}
|
||||
|
||||
[UnitySetUp]
|
||||
public override IEnumerator UnitySetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
networkManagerGo = transport.gameObject;
|
||||
manager = networkManagerGo.AddComponent<NetworkManager>();
|
||||
Transport.activeTransport = transport;
|
||||
|
||||
// create a tracked prefab (not spawned)
|
||||
CreateGameObject(out playerGO);
|
||||
identity = playerGO.AddComponent<NetworkIdentity>();
|
||||
identity.assetId = System.Guid.NewGuid();
|
||||
|
||||
manager.playerPrefab = playerGO;
|
||||
manager.autoStartServerBuild = false;
|
||||
manager.autoCreatePlayer = AutoAddPlayer;
|
||||
|
||||
if (Application.isBatchMode)
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
manager.StartHost();
|
||||
|
||||
yield return null;
|
||||
|
||||
afterStartHost();
|
||||
}
|
||||
|
||||
[UnityTearDown]
|
||||
public override IEnumerator UnityTearDown()
|
||||
{
|
||||
beforeStopHost();
|
||||
|
||||
yield return null;
|
||||
|
||||
// needed for stophost
|
||||
Transport.activeTransport = transport;
|
||||
manager.StopHost();
|
||||
|
||||
base.TearDown();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed9f33fa2d684c64cb12abd81ecdc849
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user