mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkBehaviourTests: IsServerOnly
This commit is contained in:
parent
15915f573e
commit
8f9064a923
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user