public void ShouldPassAndValidation() { var obj = new { Name = "Ashish", Goals = 15, Fouls = 100 }; var validator = obj.Validate() .And("Some validation failed", o => o.Validate().IsNotNull(v => v, "Object should be null"), o => o.Validate().IsNotNull(v => v.Name, "Name should be null") ); Assert.IsTrue(validator.IsValid); }
public void ShouldFailAndValidation() { var obj = new { Name = "Ashish", Goals = 15, Fouls = 100 }; var validator = obj.Validate() .And("Some validation failed", o => o.Validate().IsNotNull(v => v, "Object should be null"), o => o.Validate().IsNull(v => v.Name, "Name should be null"), o => o.Validate().IsGreaterThan(v => v.Goals, 20, "Should have more than 20 goals") ); Assert.IsFalse(validator.IsValid); }