public void Validate_WhenRuleIsHonored_ThenValidatableObjectShouldBeValid() { _validatableObject.AddValidationRule(_mockValidationRule); _mockValidationRule.SetCheckReturnValueTo(true); _validatableObject.Validate(); Assert.True(_validatableObject.IsValid); }
public void Validate_WhenRuleIsHonored_ThenValidatableObjectShouldBeValid() { _validatableObject.AddValidationRule(_mockValidationRule.Object); _mockValidationRule .Setup(v => v.Check(It.IsAny <string>())) .Returns(true); _validatableObject.Validate(); _validatableObject.IsValid.Should().BeTrue(); }
public void TestFirstValidationRule_secondError() { //arrange var name = new ValidatableObject <string>(); name.AddValidationRule(new IsNotNullOrEmptyRule <string>("Must have value")); name.AddValidationRule(new IsValidEmailValidationRule("Invalid Email")); //act name.Value = "John"; name.Validate(); //assert var actual = _converter.Convert(name.Errors, null, null, CultureInfo.CurrentCulture); Assert.AreEqual("Invalid Email", actual); }
private void AddValidationRulesToValidatable() { var isBiggerThanZero = new IsBiggerThanZero <float> { ErrorMessage = UiText.DOG_NEED_A_GOOD_PRICE }; var haveAName = new HaveAName <string> { ErrorMessage = UiText.DOG_NEED_A_NAME }; _name.AddValidationRule(haveAName); _price.AddValidationRule(isBiggerThanZero); }