Exemplo n.º 1
0
        public void ValidatePassword_validates_a_good_password()
        {
            var sut = new PasswordComplexityValidator();

            var result = sut.ValidatePassword("username", "12345678aA!", out var errorMessage);

            result.Should().BeTrue();
            errorMessage.Should().BeNull();
        }
Exemplo n.º 2
0
        public void ValidatePassword_gives_error_when_password_is_too_short()
        {
            var sut = new PasswordComplexityValidator();

            var result = sut.ValidatePassword("UserName", "1234567", out var errorMessage);

            result.Should().BeFalse();
            errorMessage.Should().Contain("Password needs to be at least 8 characters long.");
        }
Exemplo n.º 3
0
        public void ValidatePassword_gives_error_when_password_misses_special_chars()
        {
            var sut = new PasswordComplexityValidator();

            var result = sut.ValidatePassword("UserName", "aaaaAAAA1", out var errorMessage);

            result.Should().BeFalse();
            errorMessage.Should().Contain("Password must contain at least one special character.");
        }
Exemplo n.º 4
0
        public void ValidatePassword_gives_error_when_username_and_password_match()
        {
            var sut = new PasswordComplexityValidator();

            var result = sut.ValidatePassword("username", "username", out var errorMessage);

            result.Should().BeFalse();
            errorMessage.Should().Contain("Username and password must not be the same.");
        }