public void MessagesAreNotConsumedIfDuplicateInQueue()
        {
            Stub.On(this.controller).GetProperty("Messages").Will(Return.Value(new object[] { "hello", "test", "world" }));

            BeforeConsumeMessageEventArgs e = new BeforeConsumeMessageEventArgs(this, "test");

            Fire.On(this.controller).Event("BeforeConsumeMessage").With(this, e);

            Assert.IsTrue(e.Cancel);
        }
        public void MessagesAreNotConsumedIfDuplicateInQueue()
        {
            A.CallTo(() => this.controller.Messages).Returns(new object[] { "hello", "test", "world" });

            BeforeConsumeMessageEventArgs e = new BeforeConsumeMessageEventArgs(this, "test");

            this.controller.BeforeConsumeMessage += Raise.With(e).Now;

            e.Cancel.Should().BeTrue();
        }
        public void MessagesAreConsumedIfNoMessageInQueue()
        {
            Stub.On(this.controller).GetProperty("Messages").Will(Return.Value(new object[] { }));

            BeforeConsumeMessageEventArgs e = new BeforeConsumeMessageEventArgs(this, "test");

            Fire.On(this.controller).Event("BeforeConsumeMessage").With(this, e);

            Assert.IsFalse(e.Cancel);
        }
        public void MessagesAreConsumedIfNoMessageInQueue()
        {
            A.CallTo(() => this.controller.Messages).Returns(new object[] { });

            BeforeConsumeMessageEventArgs e = new BeforeConsumeMessageEventArgs(this, "test");

            this.controller.BeforeConsumeMessage += Raise.With(e).Now;

            e.Cancel.Should().BeFalse();
        }
コード例 #5
0
        /// <summary>
        /// Fires the <see cref="BeforeConsumeMessage"/> event.
        /// </summary>
        /// <param name="message">The message that will be consumed.</param>
        /// <returns>False if the handler canceled to consume of the message.</returns>
        private bool OnBeforeConsumeMessage(object message)
        {
            if (this.BeforeConsumeMessage == null)
            {
                return(true);
            }

            BeforeConsumeMessageEventArgs e = new BeforeConsumeMessageEventArgs(this.controlledModule, message);

            this.BeforeConsumeMessage(this, e);

            return(!e.Cancel);
        }