public void IValidator_AddBusinessRuleErrors() { var validator = new TestValidator(); var classWithValidator = new ClassWithValidator() as IValidatable; classWithValidator.Validator = validator; classWithValidator.Validate(true); var dataErrorInfo = (IDataErrorInfo)classWithValidator; Assert.AreEqual("Error", dataErrorInfo.Error); }
public void IValidator_AddFieldErrors() { var validator = new TestValidator(); var classWithValidator = new ClassWithValidator() as IValidatable; classWithValidator.Validator = validator; classWithValidator.Validate(true); var dataWarningInfo = (IDataWarningInfo)classWithValidator; var dataErrorInfo = (IDataErrorInfo)classWithValidator; Assert.AreEqual("Warning", dataWarningInfo[ClassWithValidator.WarningPropertyProperty.Name]); Assert.AreEqual("Error", dataErrorInfo[ClassWithValidator.ErrorPropertyProperty.Name]); }
public void IValidator_CheckIfEventsAreFired() { var validator = new TestValidator(); var classWithValidator = new ClassWithValidator() as IValidatable; classWithValidator.Validator = validator; classWithValidator.Validate(true); Assert.AreEqual(1, validator.ValidateCount); Assert.AreEqual(1, validator.BeforeValidationCount); Assert.AreEqual(1, validator.BeforeValidateFieldsCount); Assert.AreEqual(1, validator.ValidateFieldsCount); Assert.AreEqual(1, validator.AfterValidateFieldsCount); Assert.AreEqual(1, validator.BeforeValidateBusinessRulesCount); Assert.AreEqual(1, validator.ValidateBusinessRulesCount); Assert.AreEqual(1, validator.AfterValidateBusinessRulesCount); Assert.AreEqual(1, validator.AfterValidationCount); }