public void DenyWhileChangingOfRunningMessageConsumer() { IMessageSource <TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate); var factory = new TestRouterFactory(new Waiter(waitablesCount: 1), messages => messages.CheckOrder(TestRouterHelper.Sequence(0, TestRouterHelper.MessagesCountToGenerate))); using (IMessageConsumer <TestMessage> consumer = factory.CreateConsumer(source)) { consumer.Consume(TestRouterHelper.HandleMessage); consumer.While = null; } }
public void CheckOrderTest() { IMessageSource <TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate); var waiter = new Waiter(waitablesCount: 1); var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.Sequence(0, TestRouterHelper.MessagesCountToGenerate))); using (IMessageConsumer <TestMessage> consumer = factory.CreateConsumer(source)) { consumer.Consume(TestRouterHelper.HandleMessage); waiter.Wait(true); } }
public void SwallowExceptionTest() { const int errorMessageIndex = 5; var waiter = new Waiter(waitablesCount: 1); IMessageSource <TestMessage> source = MessageGenerator.CreateSource(TestRouterHelper.SourceName, TestRouterHelper.MessagesCountToGenerate, errorMessageIndex, swallowException: true); var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.SequenceExcluding(0, TestRouterHelper.MessagesCountToGenerate, errorMessageIndex))); using (IMessageConsumer <TestMessage> consumer = factory.CreateConsumer(source)) { consumer.Consume(TestRouterHelper.HandleMessage); waiter.Wait(true); } }
public void ChildrenOrderTest() { const int sourcesCount = 5; IMessageSource <TestMessage> source = MessageGenerator.CreateCompositeSource(TestRouterHelper.SourceName, sourcesCount, TestRouterHelper.MessagesCountToGenerate); var waiter = new Waiter(sourcesCount); var factory = new TestRouterFactory(waiter, messages => messages.CheckOrder(TestRouterHelper.Sequence(0, TestRouterHelper.MessagesCountToGenerate))); using (IMessageConsumer <TestMessage> router = factory.CreateRouter(source, factory, m => m.Tag)) { router.Consume(TestRouterHelper.HandleMessage); waiter.Wait(true); // we compare to 55, not 50, because each source has stop message at the end. ((TestMessageRouter)router).ReceiveCallCount.Should(Be.EqualTo(55)); } }