public async Task Should_receive_a_two_messages()
        {
            IConsumePipe filter = CreateConsumePipe();

            TwoMessageConsumer consumer = GetTwoMessageConsumer();

            IConsumerFactory <TwoMessageConsumer> factory = GetInstanceConsumerFactory(consumer);

            filter.ConnectConsumer(factory);

            await filter.Send(new TestConsumeContext <MessageA>(new MessageA()));

            await filter.Send(new TestConsumeContext <MessageB>(new MessageB()));

            await consumer.TaskA;
            await consumer.TaskB;
        }
Beispiel #2
0
        public async Task Should_receive_a_test_message()
        {
            IConsumePipe filter = CreateConsumePipe();

            TaskCompletionSource <PingMessage> received = GetTask <PingMessage>();

            ConnectHandle connectHandle = filter.ConnectHandler <PingMessage>(async context =>
                                                                              received.TrySetResult(context.Message));

            var consumeContext = new TestConsumeContext <PingMessage>(new PingMessage());

            await filter.Send(consumeContext);

            await received.Task;
        }
        public async Task Should_receive_a_message_via_object()
        {
            IConsumePipe filter = CreateConsumePipe();

            OneMessageConsumer consumer = GetOneMessageConsumer();

            object subscribeConsumer = consumer;

            filter.ConnectInstance(subscribeConsumer);

            var consumeContext = new TestConsumeContext <MessageA>(new MessageA());

            await filter.Send(consumeContext);

            await consumer.Task;
        }
        public async Task Should_receive_a_message()
        {
            IConsumePipe filter = CreateConsumePipe();

            OneMessageConsumer consumer = GetOneMessageConsumer();

            IConsumerFactory <OneMessageConsumer> factory = GetInstanceConsumerFactory(consumer);

            filter.ConnectConsumer(factory);

            var consumeContext = new TestConsumeContext <MessageA>(new MessageA());

            await filter.Send(consumeContext);

            await consumer.Task;
        }
Beispiel #5
0
        public void Should_invoke_faulted()
        {
            IConsumePipe filter = CreateConsumePipe();

            filter.ConnectHandler <MessageA>(async context =>
            {
                throw new IntentionalTestException("This is a test");
            });

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            Assert.Throws <IntentionalTestException>(async() => await filter.Send(consumeContext));

            Assert.Throws <IntentionalTestException>(async() => await interceptor.ConsumeFaulted);
        }
Beispiel #6
0
        public async Task Should_invoke_pre()
        {
            IConsumePipe filter = CreateConsumePipe();

            TaskCompletionSource <MessageA> received = GetTask <MessageA>();

            filter.ConnectHandler <MessageA>(async context => received.TrySetResult(context.Message));

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            await filter.Send(consumeContext);

            await received.Task;

            await interceptor.PreConsumed;
        }
Beispiel #7
0
        public async Task Should_invoke_post_consumer()
        {
            IConsumePipe filter = CreateConsumePipe();

            TaskCompletionSource <MessageA> received = GetTask <MessageA>();

            filter.ConnectConsumer(() => new OneMessageConsumer(received));

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            await filter.Send(consumeContext);

            await received.Task;

            await interceptor.PostConsumed;
        }