public void MessageForNonExistingPropertyIsEmptyString()
        {
            var instance = new ValidatedClass();
            var helper = new DataErrorInfoHelper(instance);

            var message = helper["NonExisting"];

            Assert.AreEqual("", message);
        }
        public void MessageForValidPropertyIsEmptyString()
        {
            var instance = new ValidatedClass { ValidatedIntProperty = 17 };
            var helper = new DataErrorInfoHelper(instance);

            var message = helper["ValidatedIntProperty"];

            Assert.AreEqual("", message);
        }
        public void MessageForEntireObjectIsEmpty()
        {
            var instance = new ValidatedClass();
            var helper = new DataErrorInfoHelper(instance);

            var message = helper.Error;

            Assert.AreEqual("", message);
        }
        public void MessageForNonValidatedPropertyIsEmptyString()
        {
            var instance = new ValidatedClass();
            var helper   = new DataErrorInfoHelper(instance);

            var message = helper["IntProperty"];

            Assert.AreEqual("", message);
        }
        public void MessageForEntireObjectIsEmpty()
        {
            var instance = new ValidatedClass();
            var helper   = new DataErrorInfoHelper(instance);

            var message = helper.Error;

            Assert.AreEqual("", message);
        }
        public void MessageForInvalidPropertyAccordingToOneRuleContainsTheMessageInTheRule()
        {
            var instance = new ValidatedClass { ValidatedIntProperty = 10 };
            var helper = new DataErrorInfoHelper(instance);

            var message = helper["ValidatedIntProperty"];

            Assert.IsFalse(message.Contains("invalid1"));
            Assert.IsTrue(message.Contains("invalid2"));
        }
        public void MessageForInvalidPropertyAccordingToMultipleRulesContainsTheMessageInTheRules()
        {
            var instance = new ValidatedClass {
                ValidatedIntProperty = 5
            };
            var helper = new DataErrorInfoHelper(instance);

            var message = helper["ValidatedIntProperty"];

            Assert.IsTrue(message.Contains("invalid1"));
            Assert.IsTrue(message.Contains("invalid2"));
        }
        public void MessageForInvalidPropertyAccordingToRuleInRulesetContainsTheMessageInTheRule()
        {
            var instance = new ValidatedClass {
                ValidatedIntProperty = 5
            };
            var helper = new DataErrorInfoHelper(instance, ValidationSpecificationSource.All, "ruleset");

            var message = helper["ValidatedIntProperty"];

            Assert.IsFalse(message.Contains("invalid1"));
            Assert.IsFalse(message.Contains("invalid2"));
            Assert.IsTrue(message.Contains("invalid-ruleset"));
        }
        public void MessageForInvalidPropertyAccordingToRuleInRulesetContainsTheMessageInTheRule()
        {
            var instance = new ValidatedClass { ValidatedIntProperty = 5 };
            var helper = new DataErrorInfoHelper(instance, ValidationSpecificationSource.All, "ruleset");

            var message = helper["ValidatedIntProperty"];

            Assert.IsFalse(message.Contains("invalid1"));
            Assert.IsFalse(message.Contains("invalid2"));
            Assert.IsTrue(message.Contains("invalid-ruleset"));
        }