Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }