From f326520d31409c5bda650702a3dd30da583c5dbd Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 5 Mar 2020 12:21:29 +0100 Subject: [PATCH] NetworkBehvaviourTests: simplify --- .../Tests/Editor/NetworkBehaviourTests.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs index bcfc71f7b..c689f89c7 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs @@ -17,12 +17,16 @@ public class NetworkBehaviourTests { GameObject gameObject; NetworkIdentity identity; + EmptyBehaviour emptyBehaviour; // useful in most tests, but not necessarily all tests [SetUp] public void SetUp() { gameObject = new GameObject(); identity = gameObject.AddComponent(); + + // add a behaviour for testing + emptyBehaviour = gameObject.AddComponent(); } [TearDown] @@ -34,18 +38,15 @@ public void TearDown() [Test] public void IsServerOnly() { - // add a behaviour - EmptyBehaviour comp = gameObject.AddComponent(); - // start server and assign netId so that isServer is true Transport.activeTransport = Substitute.For(); 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); + Assert.That(emptyBehaviour.isServer, Is.True); + Assert.That(emptyBehaviour.isClient, Is.False); + Assert.That(emptyBehaviour.isServerOnly, Is.True); // clean up NetworkServer.Shutdown(); @@ -55,14 +56,11 @@ public void IsServerOnly() [Test] public void IsClientOnly() { - // add a behaviour - EmptyBehaviour comp = gameObject.AddComponent(); - // isClientOnly should be true when isServer = false && isClient = true identity.isClient = true; - Assert.That(comp.isServer, Is.False); - Assert.That(comp.isClient, Is.True); - Assert.That(comp.isClientOnly, Is.True); + Assert.That(emptyBehaviour.isServer, Is.False); + Assert.That(emptyBehaviour.isClient, Is.True); + Assert.That(emptyBehaviour.isClientOnly, Is.True); } } }