コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }