public void when_receiving_event_published_with_message_and_correlation_ids_then_calls_handler_with_envelope()
        {
            var processor = new EventProcessor(new SubscriptionReceiver(Settings, Topic, Subscription), new JsonTextSerializer());
            var bus       = new EventBus(new TopicSender(Settings, Topic), new StandardMetadataProvider(), new JsonTextSerializer());

            var e       = new ManualResetEventSlim();
            var handler = new FooEnvelopedEventHandler(e);

            processor.Register(handler);

            processor.Start();

            try {
                bus.Publish(new Envelope <IEvent>(new FooEvent())
                {
                    CorrelationId = "correlation", MessageId = "message"
                });

                e.Wait(TimeoutPeriod);

                Assert.True(handler.Called);
                Assert.Equal("correlation", handler.CorrelationId);
                Assert.Equal("message", handler.MessageId);
            } finally {
                processor.Stop();
            }
        }
        public void when_receiving_event_then_calls_handler_with_envelope()
        {
            var processor = new EventProcessor(new SubscriptionReceiver(this.Settings, this.Topic, this.Subscription), new JsonTextSerializer());
            var bus       = new EventBus(new TopicSender(this.Settings, this.Topic), new StandardMetadataProvider(), new JsonTextSerializer());

            var e       = new ManualResetEventSlim();
            var handler = new FooEnvelopedEventHandler(e);

            processor.Register(handler);

            processor.Start();

            try
            {
                bus.Publish(new FooEvent());

                e.Wait(TimeoutPeriod);

                Assert.True(handler.Called);
            }
            finally
            {
                processor.Stop();
            }
        }