Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 ConnectHandle IConsumeMessageObserverConnector.ConnectConsumeMessageObserver <T>(IConsumeMessageObserver <T> observer)
 {
     return(_consumePipe.ConnectConsumeMessageObserver(observer));
 }
Exemplo n.º 5
0
 public ConnectHandle ConnectConsumeMessageObserver <T>(IConsumeMessageObserver <T> observer)
     where T : class
 {
     return(_consumePipe.ConnectConsumeMessageObserver(observer));
 }