Example #1
0
        public void RouterShouldHandleMessagesIfTagIsNotProvided()
        {
            IMessageSource <TestMessage> source = MessageGenerator.CreateSource(string.Empty, 5);
            var waiter  = new Waiter(1);
            var factory = new TestRouterFactory(waiter, messages => { });

            using (IMessageConsumer <TestMessage> router = factory.CreateRouter(source, factory, m => m.Tag))
            {
                var messagesHandled = 0;
                waiter.Register(router);
                router.While = m => TestMessage.IsNotStopMessage(string.Empty, m);
                router.Consume(message => messagesHandled++);
                waiter.Wait(true);

                messagesHandled.Should(Be.EqualTo(6));
                //Do not receive message from queue, if router handles message by itself. Let the handle logic do this.
                ((TestMessageRouter)router).ReceiveCallCount.Should(Be.EqualTo(0));
            }
        }