public void IsValidWithValue2Null()
        {
            var model = new ModelWithPassOnNull {
                Value1 = "hello"
            };

            Assert.True(model.IsValid("Value2"));
        }
        public bool WithPassOnNullTest(string[] value1, string value2)
        {
            var model = new ModelWithPassOnNull {
                Value1 = value1, Value2 = value2
            };

            return(model.IsValid());
        }
        public bool WithPassOnNullTest(int?value1, int?value2)
        {
            var model = new ModelWithPassOnNull {
                Value1 = value1, Value2 = value2
            };

            return(model.IsValid());
        }
        public void WhenPassOnNull_IsNotValidWithWhenNotEqual()
        {
            var model = new ModelWithPassOnNull {
                Value1 = "hello1", Value2 = "hello"
            };

            Assert.IsFalse(model.IsValid("Value2"));
        }
        public void WhenPassOnNull_IsValidWithEqual()
        {
            var model = new ModelWithPassOnNull {
                Value1 = "hello", Value2 = "hello"
            };

            Assert.IsTrue(model.IsValid("Value2"));
        }
        public void EqualTo_PropertyValueNullAndPassOnNull_Validates()
        {
            var model = new ModelWithPassOnNull()
            {
                Value1 = "hello"
            };

            Assert.IsTrue(model.IsValid("Value2"));
        }
        public void IsValidWithValue1Null()
        {
            var model = new ModelWithPassOnNull() { Value2 = "hello" };

            var ctx = new ValidationContext(model, null, null);
            var results = new List<ValidationResult>();

            bool actual = Validator.TryValidateObject(model, ctx, results, true);
            var expected = true;
            Assert.AreEqual(actual, expected);
        }
        public void IsValidWithValue2Null()
        {
            var model = new ModelWithPassOnNull()
            {
                Value1 = "hello"
            };

            var ctx     = new ValidationContext(model, null, null);
            var results = new List <ValidationResult>();

            bool actual   = Validator.TryValidateObject(model, ctx, results, true);
            var  expected = true;

            Assert.AreEqual(actual, expected);
        }
        public void WhenPassOnNull_IsValidWithBothNull()
        {
            var model = new ModelWithPassOnNull();

            Assert.IsTrue(model.IsValid("Value2"));
        }