public void DefaultErrorMessage_PredicateValidator() { var validator = new PredicateValidator((o1, o2, o3) => true); Assert.That(validator.ErrorMessageSource, Is.TypeOf(typeof(LocalizedStringSource))); Assert.That(validator.ErrorMessageSource.GetString(), Is.EqualTo(Messages.predicate_error)); }
private static void AssertNotNullPredicate(object value) { Predicate <object> predicate = x => x != null; PredicateValidator predicateValidator = new PredicateValidator(predicate); Assert.AreEqual(predicate(value), predicateValidator.IsValid(value)); }
public void ShouldBeInvalidIfPredicateIsFalse() { // Arrange var validator = new PredicateValidator <int>(i => i > 0); // Act validator.Validate(0); // Assert validator.IsInvalid.ShouldBe(true); }
public void ShouldBeDirtyOnceValidated() { // Arrange var validator = new PredicateValidator <int>(i => i > 0); // Act validator.Validate(1); // Assert validator.IsDirty.ShouldBe(true); }
public void GetValidator() { Predicate <object> predicate = x => true; PredicateValidationAttribute predicateValidationAttribute = new PredicateValidationAttribute(predicate); Assert.IsInstanceOf(typeof(PredicateValidator), predicateValidationAttribute.GetValidator()); PredicateValidator predicateValidator = (PredicateValidator)predicateValidationAttribute.GetValidator(); Assert.AreEqual(predicate, predicateValidator.Predicate); }
public void Validate_WithPredicate_Valid() { //Arrange IValueValidator <Guy> workingAgeValidator = new PredicateValidator <Guy>(g => g.Age >= 18, new PredicateValidator <Guy>(g => g.Age <= 80)); //Act bool valid = workingAgeValidator.IsValid(_guy); //Assert Assert.True(valid); }
public void Setup() { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); validator = new PredicateValidator((person, forename) => forename == "Jeremy"); }