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 invocation     = new ScanCommand1().ToInvocation(messageContext);

            invoker.InvokeMessageHandlerAsync(invocation).RunSynchronously();

            invocation.ApplyContextCalled.ShouldBeTrue();
        }
        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.Message).Returns(new ScanCommand1());

            invoker.InvokeMessageHandlerAsync(invocationMock.Object).RunSynchronously();

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