public void should_publish_command_to_executor() { var commandA = new CommandA(); Subject.PublishCommand(commandA); _executorA.Verify(c => c.Execute(commandA), Times.Once()); }
public void should_publish_executed_event_on_success() { var commandA = new CommandA(); Subject.PublishCommand(commandA); VerifyEventPublished <CommandExecutedEvent>(); }
public void broken_executor_should_throw_the_exception() { var commandA = new CommandA(); _executorA.Setup(c => c.Execute(It.IsAny <CommandA>())) .Throws(new NotImplementedException()); Assert.Throws <NotImplementedException>(() => Subject.PublishCommand(commandA)); }
public void should_not_publish_to_incompatible_executor() { var commandA = new CommandA(); Subject.PublishCommand(commandA); _executorA.Verify(c => c.Execute(commandA), Times.Once()); _executorB.Verify(c => c.Execute(It.IsAny <CommandB>()), Times.Never()); }
public void should_execute_on_executor() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; Subject.Handle(new ApplicationStartedEvent()); QueueAndWaitForExecution(commandModel); _executorA.Verify(c => c.Execute(commandA), Times.Once()); }
public void should_publish_executed_event_on_success() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; Subject.Handle(new ApplicationStartedEvent()); QueueAndWaitForExecution(commandModel); VerifyEventPublished <CommandExecutedEvent>(); }
public void should_use_completion_message() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; Subject.Handle(new ApplicationStartedEvent()); QueueAndWaitForExecution(commandModel); Mocker.GetMock <IManageCommandQueue>() .Verify(s => s.Complete(It.Is <CommandModel>(c => c == commandModel), commandA.CompletionMessage), Times.Once()); }
public void should_not_execute_on_incompatible_executor() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; Subject.Handle(new ApplicationStartedEvent()); _commandQueue.Add(commandModel); WaitForExecution(commandModel); _executorA.Verify(c => c.Execute(commandA), Times.Once()); _executorB.Verify(c => c.Execute(It.IsAny <CommandB>()), Times.Never()); }
public void should_use_last_progress_message_if_completion_message_is_null() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA, Message = "Do work" }; Subject.Handle(new ApplicationStartedEvent()); QueueAndWaitForExecution(commandModel); Mocker.GetMock <IManageCommandQueue>() .Setup(s => s.Complete(It.Is <CommandModel>(c => c == commandModel), commandModel.Message)) .Callback(() => _commandExecuted = true); }
public void should_use_completion_message() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; Subject.Handle(new ApplicationStartedEvent()); _commandQueue.Add(commandModel); WaitForExecution(commandModel); Mocker.GetMock <IManageCommandQueue>() .Setup(s => s.Complete(It.Is <CommandModel>(c => c == commandModel), commandA.CompletionMessage)) .Callback(() => _commandExecuted = true); }
public void broken_executor_should_publish_executed_event() { GivenCommandQueue(); var commandA = new CommandA(); var commandModel = new CommandModel { Body = commandA }; _executorA.Setup(s => s.Execute(It.IsAny <CommandA>())) .Throws(new NotImplementedException()); Subject.Handle(new ApplicationStartedEvent()); QueueAndWaitForExecution(commandModel); VerifyEventPublished <CommandExecutedEvent>(); ExceptionVerification.ExpectedErrors(1); }