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 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); }
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; }