public void should_build_and_run_pipe_invocation() { _messageDispatcher.LoadMessageHandlerInvokers(); var command = new ScanCommand1(); Dispatch(command); _invocation.ShouldNotBeNull(); _invocation.WasRun.ShouldBeTrue(); }
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(); }
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); }
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()); }
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_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); }