public async Task IfEnricherException_ErrorsAreCaptured()
        {
            // Arrange:
            var enricher1 = new MessageEnricherOne
            {
                ExpectedException = new InvalidOperationException("ENRICHER_MESSAGE_1")
            };

            var enricher2 = new MessageEnricherOne
            {
                ExpectedException = new InvalidOperationException("ENRICHER_MESSAGE_2")
            };

            var publisher = new MessagePublisherOne();

            var dispatcher = SetupDispatcher(config =>
            {
                config.AddEnricher <MessageEnricherOne>();
                config.AddEnricher <MessageEnricherTwo>();
                config.AddPublisher <MessagePublisherOne>();
            },
                                             new[] { enricher1, enricher2 },
                                             new[] { publisher });

            var command = new TestCommand();

            try
            {
                // Act:
                await dispatcher.SendAsync(command);
            }
            catch (PublisherException ex)
            {
                // Assert:
                // ...The publisher exception has a list of exceptions for each failed enricher.
                Assert.NotNull(ex.ExceptionDetails);
                Assert.Equal(2, ex.ExceptionDetails.Count());
                Assert.True(ex.ExceptionDetails.All(dEx => dEx.GetType() == typeof(EnricherException)));

                // ... Each enricher exception will have an inner-exception referencing the actual
                // ... exception thrown by the enricher:
                Assert.True(ex.ExceptionDetails.All(dEx => dEx.InnerException.GetType() == typeof(InvalidOperationException)));

                var messages = ex.ExceptionDetails.Select(dEx => dEx.InnerException.Message).ToArray();
                Assert.Contains("ENRICHER_MESSAGE_1", messages);
                Assert.Contains("ENRICHER_MESSAGE_2", messages);

                // ... If an enricher fails, message publishers are not called.
                Assert.DoesNotContain(command.CallSequence, cs => cs == typeof(MessagePublisher));
            }
        }
        public async Task AllMessageEnrichersInvoked_BeforeProviders()
        {
            // Arrange
            var enricher  = new MessageEnricherOne();
            var publisher = new MessagePublisherOne();

            var dispatcher = SetupDispatcher(config =>
            {
                config.AddEnricher <MessageEnricherOne>();
                config.AddPublisher <MessagePublisherOne>();
            },
                                             new[] { enricher },
                                             new[] { publisher });

            // Act
            var command = new TestCommand();
            await dispatcher.SendAsync(command);

            // Assert
            Assert.Equal(2, command.CallSequence.Count);
            Assert.Equal(typeof(MessageEnricherOne), command.CallSequence.ElementAt(0));
            Assert.Equal(typeof(MessagePublisherOne), command.CallSequence.ElementAt(1));
        }