public void Validate_SuccessfullyValidatesNotExistingNames() { Func <IEnumerable <string> > getExistingNames = () => { return(new string[] { "Blank" }); }; var validator = new ExistingNamesValidator(getExistingNames); var result = validator.Validate("Blank1"); Assert.True(result.IsValid); Assert.True(result.Errors.Count == 0); }
public void Validate_SuccessfullyIdentifiesExistingNames() { Func <IEnumerable <string> > getExistingNames = () => { return(new string[] { "Blank" }); }; var validator = new ExistingNamesValidator(getExistingNames); var result = validator.Validate("Blank"); Assert.False(result.IsValid); Assert.True(result.Errors.Count == 1); Assert.Equal(ValidationErrorType.AlreadyExists, result.Errors.FirstOrDefault()?.ErrorType); Assert.Equal(nameof(ExistingNamesValidator), result.Errors.FirstOrDefault()?.ValidatorName); }
public void ExistingNamesValidator_NullConfig() { var validator = new ExistingNamesValidator(null); Assert.Throws <ArgumentNullException>(() => validator.Validate("Blank")); }