public async Task CanRestoreIdentity()
 {
     var step = new RestorePrincipalFromIncomingMessage(new DummySerializer());
     var instance = new Message(new Dictionary<string, string>(), new object());
     var context = new IncomingStepContext(new TransportMessage(new Dictionary<string, string>(), new byte[0] ), new DefaultTransactionContext() );
     instance.Headers[CapturePrincipalInOutgoingMessage.PrincipalCaptureKey] = "Larry";
     context.Save(instance);
     await step.Process(context, async () =>
     {
         Assert.AreEqual(ClaimsPrincipal.Current.Identity.Name, "Larry");
     });
 }
        /// <summary>
        /// Propagates the ClaimsPrincipal through the message bus so that its there during message evaluation
        /// </summary>
        public static void AutomaticallyPropagateCurrentClaimsPrincipal(this OptionsConfigurer configurer)
        {
            if (!configurer.Has<IClaimsPrinicpalSerializer>())
            {
                configurer.Register<IClaimsPrinicpalSerializer>(c => new DefaultClaimsPrinicpalSerializer());
            }

            configurer.Decorate<IPipeline>(c =>
            {
                var pipeline = c.Get<IPipeline>();
                var serializer = c.Get<IClaimsPrinicpalSerializer>();
                var outgoingStep = new CapturePrincipalInOutgoingMessage(serializer);
                var incomingStep = new RestorePrincipalFromIncomingMessage(serializer);

                return new PipelineStepInjector(pipeline)
                    .OnSend(outgoingStep, PipelineRelativePosition.After, typeof(AssignTypeHeaderStep))
                    .OnReceive(incomingStep, PipelineRelativePosition.Before, typeof(ActivateHandlersStep));
            });
        }