mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
adding test for NetworkServer.Destroy (#2115)
This commit is contained in:
parent
0f09702062
commit
2b6a1bb792
@ -1,5 +1,7 @@
|
|||||||
|
using System.Collections;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
|
||||||
namespace Mirror.Tests.Runtime
|
namespace Mirror.Tests.Runtime
|
||||||
{
|
{
|
||||||
@ -22,8 +24,8 @@ public void TearDown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// prevents https://github.com/vis2k/Mirror/issues/1484
|
// prevents https://github.com/vis2k/Mirror/issues/1484
|
||||||
[Test]
|
[UnityTest]
|
||||||
public void OnDestroyIsServerTrue()
|
public IEnumerator OnDestroyIsServerTrue()
|
||||||
{
|
{
|
||||||
// call OnStartServer so that isServer is true
|
// call OnStartServer so that isServer is true
|
||||||
identity.OnStartServer();
|
identity.OnStartServer();
|
||||||
@ -35,7 +37,29 @@ public void OnDestroyIsServerTrue()
|
|||||||
GameObject.Destroy(gameObject);
|
GameObject.Destroy(gameObject);
|
||||||
|
|
||||||
// make sure that isServer is still true so we can save players etc.
|
// make sure that isServer is still true so we can save players etc.
|
||||||
Assert.That(identity.isServer, Is.EqualTo(true));
|
Assert.That(identity.isServer, Is.True);
|
||||||
|
|
||||||
|
yield return null;
|
||||||
|
// Confirm it has been destroyed
|
||||||
|
Assert.That(identity == null, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnityTest]
|
||||||
|
public IEnumerator OnDestroyIsServerTrueWhenNetworkServerDestroyIsCalled()
|
||||||
|
{
|
||||||
|
// call OnStartServer so that isServer is true
|
||||||
|
identity.OnStartServer();
|
||||||
|
Assert.That(identity.isServer, Is.True);
|
||||||
|
|
||||||
|
// destroy it
|
||||||
|
NetworkServer.Destroy(gameObject);
|
||||||
|
|
||||||
|
// make sure that isServer is still true so we can save players etc.
|
||||||
|
Assert.That(identity.isServer, Is.True);
|
||||||
|
|
||||||
|
yield return null;
|
||||||
|
// Confirm it has been destroyed
|
||||||
|
Assert.That(identity == null, Is.True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user