adjust tests

This commit is contained in:
vis2k 2022-02-01 17:50:00 +08:00
parent 61cf08e01b
commit d618582f41
2 changed files with 11 additions and 4 deletions

View File

@ -16,14 +16,22 @@ public abstract class MirrorTest
public List<GameObject> instantiated; public List<GameObject> instantiated;
// we usually need the memory transport // we usually need the memory transport
GameObject holder;
public MemoryTransport transport; public MemoryTransport transport;
public virtual void SetUp() public virtual void SetUp()
{ {
instantiated = new List<GameObject>(); instantiated = new List<GameObject>();
// need a holder GO
holder = new GameObject();
// need a transport to send & receive // need a transport to send & receive
Transport.activeTransport = transport = new GameObject().AddComponent<MemoryTransport>(); Transport.activeTransport = transport = holder.AddComponent<MemoryTransport>();
// NetworkServer was static before (= always existed).
// so always create the component again.
NetworkServerComponent.singleton = holder.AddComponent<NetworkServerComponent>();
} }
public virtual void TearDown() public virtual void TearDown()
@ -41,7 +49,8 @@ public virtual void TearDown()
if (go != null) if (go != null)
GameObject.DestroyImmediate(go); GameObject.DestroyImmediate(go);
GameObject.DestroyImmediate(transport.gameObject); GameObject.DestroyImmediate(holder);
NetworkServerComponent.singleton = null;
Transport.activeTransport = null; Transport.activeTransport = null;
} }

View File

@ -24,8 +24,6 @@ public override void SetUp()
public override void TearDown() public override void TearDown()
{ {
base.TearDown(); base.TearDown();
// clear server aoi again
NetworkServer.aoi = null;
} }
// brute force interest management // brute force interest management