public void TestObjectThree_TestProepertyNotSetToTriggerText(string propertyEight) { //Arrange var testObject = new TestObjectThree(); testObject.PropertyEight = propertyEight; //Act var validationResults = new List <ValidationResult>(); var ctx = new ValidationContext(testObject, null, null); Validator.TryValidateObject(testObject, ctx, validationResults, true); //Assert Assert.AreEqual(0, validationResults.Count()); }
public void TestObjectThree_DateBlankOther_ExpectedMessage() { //Arrange //Arrange var testObject = new TestObjectThree(); testObject.PropertyEight = "OtherTestValue"; //Act var validationResults = new List <ValidationResult>(); var ctx = new ValidationContext(testObject, null, null); Validator.TryValidateObject(testObject, ctx, validationResults, true); //Assert Assert.AreEqual("The PropertySeven field is required.", validationResults[0].ErrorMessage); }
public void TestObjectThree_TestProepertySetToTrigerMessageButOtherValueSet(int dayCount) { //Arrange var testObject = new TestObjectThree(); testObject.PropertySeven = DateTime.Now.AddDays(dayCount); testObject.PropertyEight = "OtherTestValue"; //Act var validationResults = new List <ValidationResult>(); var ctx = new ValidationContext(testObject, null, null); Validator.TryValidateObject(testObject, ctx, validationResults, true); //Assert Assert.AreEqual(0, validationResults.Count()); }