Пример #1
0
        public void should_publish_command_to_executor()
        {
            var commandA = new CommandA();

            Subject.PublishCommand(commandA);

            _executorA.Verify(c => c.Execute(commandA), Times.Once());
        }
Пример #2
0
        public void should_publish_executed_event_on_success()
        {
            var commandA = new CommandA();

            Subject.PublishCommand(commandA);

            VerifyEventPublished <CommandExecutedEvent>();
        }
Пример #3
0
        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));
        }
Пример #4
0
        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());
        }
Пример #5
0
        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());
        }
Пример #6
0
        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>();
        }
Пример #7
0
        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());
        }
Пример #8
0
        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());
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }