public async Task ManuallyComposedSyncAsyncTypeAsynchronouslyHandlesMessageProperly() { var message2 = new Message2 { CorrelationId = "1234" }; var bus = new Bus(); var message3AsyncConsumer = new Message3AsyncConsumer(); bus.AddHandler(message3AsyncConsumer); var pipe = new Pipe23(); bus.AddTranslator(pipe); await bus.HandleAsync(message2); Assert.AreSame(message2, Pipe23.LastMessageProcessed); Assert.IsNotNull(Message3AsyncConsumer.LastMessageReceived); Assert.AreEqual(message2.CorrelationId, Message3AsyncConsumer.LastMessageReceived.CorrelationId); }
public void RequestWithErrorEventThrowsWithExceptionWithEvent() { IBus bus = new Bus(); bus.AddHandler(new ActionConsumer <Message1>(m => { bus.Publish(new TheErrorEvent { CorrelationId = m.CorrelationId }); })); var exception = Assert.ThrowsAsync <ReceivedErrorEventException <TheErrorEvent> >(async() => { await bus.RequestAsync <Message1, TheEvent, TheErrorEvent>( new Message1 { CorrelationId = "12344321" }); } ); Assert.IsNotNull(exception.ErrorEvent); }
public void ManuallyComposedTypeSynchronouslyHandlesMessageProperly() { var message1 = new Message1 { CorrelationId = "1234" }; var bus = new Bus(); var message2Consumer = new Message2Consumer(); bus.AddHandler(message2Consumer); var pipe = new Pipe(); bus.AddTranslator(pipe); bus.Handle(message1); Assert.AreSame(message1, Pipe.LastMessageProcessed); Assert.IsNotNull(Message2Consumer.LastMessageReceived); Assert.AreEqual(message1.CorrelationId, Message2Consumer.LastMessageReceived.CorrelationId); }