// Generated by AttributeTestGenerator.cs using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; namespace Mirror.Tests.Attributes { public class ClassWithNoConstructor { public int a; } public class ClassWithConstructor { public int a; public ClassWithConstructor(int a) { this.a = a; } } public class AttributeBehaviour_NetworkBehaviour : NetworkBehaviour { public static readonly float Expected_float = 2020f; [Client] public float Client_float_Function() { return Expected_float; } [Client] public void Client_float_out_Function(out float value) { value = Expected_float; } [Server] public float Server_float_Function() { return Expected_float; } [Server] public void Server_float_out_Function(out float value) { value = Expected_float; } [ClientCallback] public float ClientCallback_float_Function() { return Expected_float; } [ClientCallback] public void ClientCallback_float_out_Function(out float value) { value = Expected_float; } [ServerCallback] public float ServerCallback_float_Function() { return Expected_float; } [ServerCallback] public void ServerCallback_float_out_Function(out float value) { value = Expected_float; } } public class AttributeTest_NetworkBehaviour { AttributeBehaviour_NetworkBehaviour behaviour; GameObject go; [SetUp] public void SetUp() { go = new GameObject(); behaviour = go.AddComponent(); } [TearDown] public void TearDown() { NetworkClient.connectState = ConnectState.None; NetworkServer.active = false; UnityEngine.Object.DestroyImmediate(go); } [Test] [TestCase(true)] [TestCase(false)] public void Client_float_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Single Mirror.Tests.Attributes.AttributeBehaviour_NetworkBehaviour::Client_float_Function()' called when client was not active"); } float actual = behaviour.Client_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_float_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_NetworkBehaviour::Client_float_out_Function(System.Single&)' called when client was not active"); } behaviour.Client_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_float_returnsValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Single Mirror.Tests.Attributes.AttributeBehaviour_NetworkBehaviour::Server_float_Function()' called when server was not active"); } float actual = behaviour.Server_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_float_setsOutValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_NetworkBehaviour::Server_float_out_Function(System.Single&)' called when server was not active"); } behaviour.Server_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_float_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; float actual = behaviour.ClientCallback_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_float_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; behaviour.ClientCallback_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_float_returnsValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; float actual = behaviour.ServerCallback_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_float_setsOutValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_NetworkBehaviour.Expected_float : default; behaviour.ServerCallback_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } } public class AttributeBehaviour_MonoBehaviour : MonoBehaviour { public static readonly float Expected_float = 2020f; public static readonly ClassWithNoConstructor Expected_ClassWithNoConstructor = new ClassWithNoConstructor { a = 10 }; public static readonly ClassWithConstructor Expected_ClassWithConstructor = new ClassWithConstructor(29); [Client] public float Client_float_Function() { return Expected_float; } [Client] public void Client_float_out_Function(out float value) { value = Expected_float; } [Client] public ClassWithNoConstructor Client_ClassWithNoConstructor_Function() { return Expected_ClassWithNoConstructor; } [Client] public void Client_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor value) { value = Expected_ClassWithNoConstructor; } [Client] public ClassWithConstructor Client_ClassWithConstructor_Function() { return Expected_ClassWithConstructor; } [Client] public void Client_ClassWithConstructor_out_Function(out ClassWithConstructor value) { value = Expected_ClassWithConstructor; } [Server] public float Server_float_Function() { return Expected_float; } [Server] public void Server_float_out_Function(out float value) { value = Expected_float; } [Server] public ClassWithNoConstructor Server_ClassWithNoConstructor_Function() { return Expected_ClassWithNoConstructor; } [Server] public void Server_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor value) { value = Expected_ClassWithNoConstructor; } [Server] public ClassWithConstructor Server_ClassWithConstructor_Function() { return Expected_ClassWithConstructor; } [Server] public void Server_ClassWithConstructor_out_Function(out ClassWithConstructor value) { value = Expected_ClassWithConstructor; } [ClientCallback] public float ClientCallback_float_Function() { return Expected_float; } [ClientCallback] public void ClientCallback_float_out_Function(out float value) { value = Expected_float; } [ClientCallback] public ClassWithNoConstructor ClientCallback_ClassWithNoConstructor_Function() { return Expected_ClassWithNoConstructor; } [ClientCallback] public void ClientCallback_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor value) { value = Expected_ClassWithNoConstructor; } [ClientCallback] public ClassWithConstructor ClientCallback_ClassWithConstructor_Function() { return Expected_ClassWithConstructor; } [ClientCallback] public void ClientCallback_ClassWithConstructor_out_Function(out ClassWithConstructor value) { value = Expected_ClassWithConstructor; } [ServerCallback] public float ServerCallback_float_Function() { return Expected_float; } [ServerCallback] public void ServerCallback_float_out_Function(out float value) { value = Expected_float; } [ServerCallback] public ClassWithNoConstructor ServerCallback_ClassWithNoConstructor_Function() { return Expected_ClassWithNoConstructor; } [ServerCallback] public void ServerCallback_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor value) { value = Expected_ClassWithNoConstructor; } [ServerCallback] public ClassWithConstructor ServerCallback_ClassWithConstructor_Function() { return Expected_ClassWithConstructor; } [ServerCallback] public void ServerCallback_ClassWithConstructor_out_Function(out ClassWithConstructor value) { value = Expected_ClassWithConstructor; } } public class AttributeTest_MonoBehaviour { AttributeBehaviour_MonoBehaviour behaviour; GameObject go; [SetUp] public void SetUp() { go = new GameObject(); behaviour = go.AddComponent(); } [TearDown] public void TearDown() { NetworkClient.connectState = ConnectState.None; NetworkServer.active = false; UnityEngine.Object.DestroyImmediate(go); } [Test] [TestCase(true)] [TestCase(false)] public void Client_float_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Single Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_float_Function()' called when client was not active"); } float actual = behaviour.Client_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_float_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_float_out_Function(System.Single&)' called when client was not active"); } behaviour.Client_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_ClassWithNoConstructor_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'Mirror.Tests.Attributes.ClassWithNoConstructor Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_ClassWithNoConstructor_Function()' called when client was not active"); } ClassWithNoConstructor actual = behaviour.Client_ClassWithNoConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_ClassWithNoConstructor_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_ClassWithNoConstructor_out_Function(Mirror.Tests.Attributes.ClassWithNoConstructor&)' called when client was not active"); } behaviour.Client_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_ClassWithConstructor_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'Mirror.Tests.Attributes.ClassWithConstructor Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_ClassWithConstructor_Function()' called when client was not active"); } ClassWithConstructor actual = behaviour.Client_ClassWithConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Client_ClassWithConstructor_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Client] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Client_ClassWithConstructor_out_Function(Mirror.Tests.Attributes.ClassWithConstructor&)' called when client was not active"); } behaviour.Client_ClassWithConstructor_out_Function(out ClassWithConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_float_returnsValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Single Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_float_Function()' called when server was not active"); } float actual = behaviour.Server_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_float_setsOutValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_float_out_Function(System.Single&)' called when server was not active"); } behaviour.Server_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_ClassWithNoConstructor_returnsValue(bool active) { NetworkServer.active = active; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'Mirror.Tests.Attributes.ClassWithNoConstructor Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_ClassWithNoConstructor_Function()' called when server was not active"); } ClassWithNoConstructor actual = behaviour.Server_ClassWithNoConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_ClassWithNoConstructor_setsOutValue(bool active) { NetworkServer.active = active; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_ClassWithNoConstructor_out_Function(Mirror.Tests.Attributes.ClassWithNoConstructor&)' called when server was not active"); } behaviour.Server_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_ClassWithConstructor_returnsValue(bool active) { NetworkServer.active = active; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'Mirror.Tests.Attributes.ClassWithConstructor Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_ClassWithConstructor_Function()' called when server was not active"); } ClassWithConstructor actual = behaviour.Server_ClassWithConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void Server_ClassWithConstructor_setsOutValue(bool active) { NetworkServer.active = active; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; if (!active) { LogAssert.Expect(LogType.Warning, "[Server] function 'System.Void Mirror.Tests.Attributes.AttributeBehaviour_MonoBehaviour::Server_ClassWithConstructor_out_Function(Mirror.Tests.Attributes.ClassWithConstructor&)' called when server was not active"); } behaviour.Server_ClassWithConstructor_out_Function(out ClassWithConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_float_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; float actual = behaviour.ClientCallback_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_float_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; behaviour.ClientCallback_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_ClassWithNoConstructor_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; ClassWithNoConstructor actual = behaviour.ClientCallback_ClassWithNoConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_ClassWithNoConstructor_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; behaviour.ClientCallback_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_ClassWithConstructor_returnsValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; ClassWithConstructor actual = behaviour.ClientCallback_ClassWithConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ClientCallback_ClassWithConstructor_setsOutValue(bool active) { NetworkClient.connectState = active ? ConnectState.Connected : ConnectState.None; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; behaviour.ClientCallback_ClassWithConstructor_out_Function(out ClassWithConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_float_returnsValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; float actual = behaviour.ServerCallback_float_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_float_setsOutValue(bool active) { NetworkServer.active = active; float expected = active ? AttributeBehaviour_MonoBehaviour.Expected_float : default; behaviour.ServerCallback_float_out_Function(out float actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_ClassWithNoConstructor_returnsValue(bool active) { NetworkServer.active = active; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; ClassWithNoConstructor actual = behaviour.ServerCallback_ClassWithNoConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_ClassWithNoConstructor_setsOutValue(bool active) { NetworkServer.active = active; ClassWithNoConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithNoConstructor : default; behaviour.ServerCallback_ClassWithNoConstructor_out_Function(out ClassWithNoConstructor actual); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_ClassWithConstructor_returnsValue(bool active) { NetworkServer.active = active; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; ClassWithConstructor actual = behaviour.ServerCallback_ClassWithConstructor_Function(); Assert.AreEqual(expected, actual); } [Test] [TestCase(true)] [TestCase(false)] public void ServerCallback_ClassWithConstructor_setsOutValue(bool active) { NetworkServer.active = active; ClassWithConstructor expected = active ? AttributeBehaviour_MonoBehaviour.Expected_ClassWithConstructor : default; behaviour.ServerCallback_ClassWithConstructor_out_Function(out ClassWithConstructor actual); Assert.AreEqual(expected, actual); } } }