Пример #1
0
        public void WarningForCommandSentWithoutAuthority()
        {
            AuthorityBehaviour hostBehaviour = CreateHostObject <AuthorityBehaviour>(false);

            const int someInt = 20;

            int callCount = 0;

            hostBehaviour.onSendInt += incomingInt =>
            {
                callCount++;
            };
            LogAssert.Expect(LogType.Warning, $"Trying to send command for object without authority. {typeof(AuthorityBehaviour).ToString()}.{nameof(AuthorityBehaviour.CmdSendInt)}");
            hostBehaviour.CmdSendInt(someInt);
            ProcessMessages();
            Assert.That(callCount, Is.Zero);
        }
Пример #2
0
        public void CommandIsSentWithAuthority()
        {
            AuthorityBehaviour hostBehaviour = CreateHostObject <AuthorityBehaviour>(true);

            const int someInt = 20;

            int callCount = 0;

            hostBehaviour.onSendInt += incomingInt =>
            {
                callCount++;
                Assert.That(incomingInt, Is.EqualTo(someInt));
            };
            hostBehaviour.CmdSendInt(someInt);
            ProcessMessages();
            Assert.That(callCount, Is.EqualTo(1));
        }