public void RubberStamp_Validator_InheritedValidator_Extended_Rule_WithWhen_Valid_Test() { var validator = new PersonValidator(); validator.AddRule(p => p.City, con => con.IsEqual("Mexico City"), r => r.When(p => p.Firstname != "Ted")); var summary = validator.Validate(new Person("Taylor", "Ted", "New York")); Assert.IsTrue(summary.IsValid); }
public void RubberStamp_Validator_InheritedValidator_Extended_Rule_CustomMessage_Invalid_Test() { var validator = new PersonValidator(); validator.AddRule(p => p.City, con => con.IsEqual("Mexico City"), r => r.SetMessage("The City has to be Mexico City")); var summary = validator.Validate(new Person("Taylor", "Ted", "New York")); Assert.IsFalse(summary.IsValid); Assert.AreEqual("The City has to be Mexico City", summary.ValidationResults.First().Message); }
public void RubberStamp_Validator_InheritedValidator_Extended_Rule_Invalid_Test() { var validator = new PersonValidator(); validator.AddRule(p => p.City, con => con.IsEqual("Mexico City")); var summary = validator.Validate(new Person("Taylor", "Ted", "New York")); Assert.IsFalse(summary.IsValid); var expected = new StringBuilder(); expected.Append("The Property City has to be equal to Mexico City"); Assert.AreEqual(expected.ToString(), summary.ValidationMessage); }