public async Task ValidateAsync_AggregatesOnlySyncErrors()
        {
            var validators           = new List <INewPasswordValidatorBase>();
            var asyncValidationError = new ValidationError("test-async");

            var mockAsyncValidator = new Mock <IAsyncNewPasswordValidator>();

            mockAsyncValidator
            .Setup(v => v.ValidateAsync(It.IsAny <INewPasswordValidationContext>()))
            .ReturnsAsync(asyncValidationError);
            validators.Add(mockAsyncValidator.Object);

            var maxLengthValidator = new MaxLengthNewPasswordValidator();

            maxLengthValidator.Configure(6);
            validators.Add(maxLengthValidator);

            var uniqueCharsValidator = new MinUniqueCharactersNewPasswordValidator();

            uniqueCharsValidator.Configure(5);
            validators.Add(uniqueCharsValidator);

            var policy  = new PasswordPolicy("test", validators, new Dictionary <string, string>());
            var context = new NewPasswordValidationContext()
            {
                Password = "******"
            };

            var errors = await policy.ValidateAsync(context);

            errors.Should().HaveCount(2);
            errors.Should().NotContain(asyncValidationError);
        }
        public void WhenMoreThanMin_ReturnsSuccess(string password)
        {
            var validator = new MinUniqueCharactersNewPasswordValidator();

            validator.Configure(3);

            var context = new NewPasswordValidationContext()
            {
                Password = password
            };

            var result = validator.Validate(context);

            result.Should().BeNull();
        }
        public void WhenLessThanMin_ReturnsError(string password)
        {
            var validator = new MinUniqueCharactersNewPasswordValidator();

            validator.Configure(3);

            var context = new NewPasswordValidationContext()
            {
                Password = password
            };

            var result = validator.Validate(context);

            result.Should().NotBeNull();
            result.ErrorCode.Should().Be(PasswordPolicyValidationErrors.MinUniqueCharacters.ErrorCode);
        }