public void should_inject_context_in_handler_constructor()
        {
            var container      = new Container(x => x.For <IBus>().Use(new Mock <IBus>().Object));
            var invoker        = new SyncMessageHandlerInvoker(container, typeof(CommandHandlerWithMessageContextInConstructor), typeof(CommandHandlerWithMessageContextInConstructorCommand));
            var messageContext = MessageContext.CreateOverride(new PeerId("Abc.Testing.0"), null);
            var command        = new CommandHandlerWithMessageContextInConstructorCommand();
            var invocation     = command.ToInvocation(messageContext);

            invoker.InvokeMessageHandler(invocation);

            command.Context.ShouldEqual(messageContext);
        }
        public void should_apply_context()
        {
            var busMock   = new Mock <IBus>();
            var handler   = new MessageContextAwareCommandHandler();
            var container = new Container(x =>
            {
                x.For <IBus>().Use(busMock.Object);
                x.ForSingletonOf <MessageContextAwareCommandHandler>().Use(handler);
            });

            var invoker        = new SyncMessageHandlerInvoker(container, typeof(MessageContextAwareCommandHandler), typeof(ScanCommand1));
            var messageContext = MessageContext.CreateOverride(new PeerId("Abc.Testing.0"), null);

            var invocationMock = new Mock <IMessageHandlerInvocation>();

            invocationMock.SetupGet(x => x.Context).Returns(messageContext);
            invocationMock.SetupGet(x => x.Messages).Returns(new List <IMessage> {
                new ScanCommand1()
            });

            invoker.InvokeMessageHandler(invocationMock.Object);

            invocationMock.Verify(x => x.SetupForInvocation(handler));
        }