adding test for NetworkServer.Destroy (#2115)

This commit is contained in:
James Frowen 2020-08-05 11:07:40 +01:00 committed by GitHub
parent 0f09702062
commit 2b6a1bb792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Mirror.Tests.Runtime
{
@ -22,8 +24,8 @@ public void TearDown()
}
// prevents https://github.com/vis2k/Mirror/issues/1484
[Test]
public void OnDestroyIsServerTrue()
[UnityTest]
public IEnumerator OnDestroyIsServerTrue()
{
// call OnStartServer so that isServer is true
identity.OnStartServer();
@ -35,7 +37,29 @@ public void OnDestroyIsServerTrue()
GameObject.Destroy(gameObject);
// 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);
}
}
}