コード例 #1
0
        public void should_build_and_run_pipe_invocation()
        {
            _messageDispatcher.LoadMessageHandlerInvokers();

            var command = new ScanCommand1();

            Dispatch(command);

            _invocation.ShouldNotBeNull();
            _invocation.WasRun.ShouldBeTrue();
        }
コード例 #2
0
        public void should_build_and_run_pipe_invocation()
        {
            _messageDispatcher.LoadMessageHandlerInvokers();

            _pipeManager.EnablePipe("TestPipe");
            var pipe = (TestPipe)_pipeManager.GetEnabledPipes(typeof(ScanCommandHandler1)).ExpectedSingle();

            var command = new ScanCommand1();

            DispatchAndWaitForCompletion(command);

            pipe.BeforeInvokeArgs.ShouldNotBeNull();
            pipe.AfterInvokeArgs.ShouldNotBeNull();
        }
コード例 #3
0
        public void should_invoke_handle_method()
        {
            _messageDispatcher.LoadMessageHandlerInvokers();

            var handler = new ScanCommandHandler1();

            _containerMock.Setup(x => x.GetInstance(typeof(ScanCommandHandler1))).Returns(handler);

            var command = new ScanCommand1();

            DispatchAndWaitForCompletion(command);

            handler.HandledCommand1.ShouldEqual(command);
        }
コード例 #4
0
        public void should_return_a_faulted_task_if_a_handler_throws()
        {
            var container = new Container(x =>
            {
                x.For <IBus>().Use(new Mock <IBus>().Object);
                x.ForSingletonOf <ErroringAsyncHandler>().Use(new ErroringAsyncHandler());
            });
            var handlerInvoker = new AsyncMessageHandlerInvoker(container, typeof(ErroringAsyncHandler), typeof(ScanCommand1));
            var messageContext = MessageContext.CreateOverride(new PeerId("Abc.Testing.0"), null);
            var invocation     = new ScanCommand1().ToInvocation(messageContext);

            var invocationTask = handlerInvoker.InvokeMessageHandlerAsync(invocation);

            Wait.Until(() => invocationTask.Status == TaskStatus.Faulted, 1.Second());
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        public void should_build_and_run_pipe_invocation()
        {
            _messageDispatcher.LoadMessageHandlerInvokers();

            var command = new ScanCommand1();
            Dispatch(command);

            _invocation.ShouldNotBeNull();
            _invocation.WasRun.ShouldBeTrue();
        }
コード例 #7
0
        public void should_invoke_handle_method()
        {
            _messageDispatcher.LoadMessageHandlerInvokers();

            var handler = new ScanCommandHandler1();
            _containerMock.Setup(x => x.GetInstance(typeof(ScanCommandHandler1))).Returns(handler);

            var command = new ScanCommand1();
            Dispatch(command);

            handler.HandledCommand1.ShouldEqual(command);
        }