Esempio n. 1
0
        public async Task ThenTheUserIsDeleted()
        {
            var command = new DeleteRegisteredUserCommand
            {
                UserRef = "TESTUSER"
            };

            await _handler.Handle(command, new CancellationToken());

            _userRepository.Verify(x => x.DeleteUser(It.Is <string>(s => s == "TESTUSER")), Times.Once);
        }
Esempio n. 2
0
        public void ThenUserRefIsMandatory()
        {
            //Arrange
            var command = new DeleteRegisteredUserCommand();

            //Act
            var result = _validator.Validate(command);

            //Assert
            Assert.IsFalse(result.IsValid);
            Assert.IsTrue(result.Errors.Any(x => x.PropertyName.Contains(nameof(DeleteRegisteredUserCommand.UserRef))));
        }
Esempio n. 3
0
        public void ThenCommandIsValidIfAllFieldsAreProvided()
        {
            //Arrange
            var command = new DeleteRegisteredUserCommand
            {
                UserRef = "UserRef"
            };

            //Act
            var result = _validator.Validate(command);

            //Assert
            Assert.IsTrue(result.IsValid);
        }
Esempio n. 4
0
        public void ThenAnExceptionIsThrownIfTheCommandIsInvalid()
        {
            //Arrange
            _validator.Setup(x => x.Validate(It.IsAny <DeleteRegisteredUserCommand>()))
            .Returns(new ValidationResult(
                         new List <ValidationFailure>
            {
                new ValidationFailure("TEST", "ERROR")
            }
                         ));

            var command = new DeleteRegisteredUserCommand();

            //Act & Assert
            Assert.ThrowsAsync <ValidationException>(() => _handler.Handle(command, new CancellationToken()));
        }