コード例 #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.SendInt)}");
            hostBehaviour.SendInt(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.SendInt(someInt);
            ProcessMessages();
            Assert.That(callCount, Is.EqualTo(1));
        }