Ejemplo n.º 1
0
        public void ThenTheValidatorIsCalled()
        {
            //Arrange
            _validator.Setup(x => x.ValidateAsync(It.IsAny <AddPayeToAccountCommand>())).ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string> {
                    { "", "" }
                }
            });

            //Act
            Assert.ThrowsAsync <InvalidRequestException>(async() => await _addPayeToAccountCommandHandler.Handle(new AddPayeToAccountCommand()));

            //Assert
            _validator.Verify(x => x.ValidateAsync(It.IsAny <AddPayeToAccountCommand>()), Times.Once);
            _accountRepository.Verify(x => x.AddPayeToAccount(It.IsAny <Paye>()), Times.Never);
            _messagePublisher.Verify(x => x.PublishAsync(It.IsAny <EmployerRefreshLevyQueueMessage>()), Times.Never);
        }