NetworkBehaviourTests: IsServerOnly

This commit is contained in:
vis2k 2020-03-05 10:09:08 +01:00
parent 15915f573e
commit 8f9064a923

View File

@ -9,6 +9,10 @@
namespace Mirror.Tests
{
class EmptyBehaviour : NetworkBehaviour
{
}
public class NetworkBehaviourTests
{
GameObject gameObject;
@ -26,5 +30,26 @@ public void TearDown()
{
GameObject.DestroyImmediate(gameObject);
}
[Test]
public void IsServerOnly()
{
// add a behaviour
EmptyBehaviour comp = gameObject.AddComponent<EmptyBehaviour>();
// start server and assign netId so that isServer is true
Transport.activeTransport = Substitute.For<Transport>();
NetworkServer.Listen(1);
identity.netId = 42;
// isServerOnly should be true when isServer = true && isClient = false
Assert.That(comp.isServer, Is.True);
Assert.That(comp.isClient, Is.False);
Assert.That(comp.isServerOnly, Is.True);
// clean up
NetworkServer.Shutdown();
Transport.activeTransport = null;
}
}
}