protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var result = ValidationResult.Success; if (value != null) { var userId = validationContext.ObjectType.GetProperty(OtherPropertyName).GetValue(validationContext.ObjectInstance, null); if (PasswordHistoryService.IsPasswordInHistory(userId.ToString(), value.ToString())) { result = new ValidationResult("This password has already been used recently, please choose another password"); } } return(result); }
public void SetUp() { this.passwordHistoryRepository = new Mock <IPasswordHistoryRepository>(); this.passwordHistoryService = new PasswordHistoryService(this.passwordHistoryRepository.Object); }