public void AttributeCreatesValidatorWithDefaultRulesetIfNoRulesetIsSupplied()
        {
            ObjectValidatorAttributeFixtureTestClass target = new ObjectValidatorAttributeFixtureTestClass();
            ValidatorAttribute validatorAttribute = new ObjectValidatorAttribute();

            Validator validator =
                ((IValidatorDescriptor)validatorAttribute)
                    .CreateValidator(
                        typeof(ObjectValidatorAttributeFixtureTestClass),
                        null,
                        null,
                        ValidationFactory.DefaultCompositeValidatorFactory);
            ValidationResults validationResults = validator.Validate(target);

            Assert.IsFalse(validationResults.IsValid);
            IDictionary<string, ValidationResult> resultsMapping = ValidationTestHelper.GetResultsMapping(validationResults);
            Assert.AreEqual(2, resultsMapping.Count);

            Assert.IsTrue(resultsMapping.ContainsKey("ObjectValidatorAttributeFixtureTestClass"));
            Assert.AreEqual(null, resultsMapping["ObjectValidatorAttributeFixtureTestClass"].Key);
            Assert.AreEqual(null, resultsMapping["ObjectValidatorAttributeFixtureTestClass"].Tag);
            Assert.AreSame(target, resultsMapping["ObjectValidatorAttributeFixtureTestClass"].Target);

            Assert.IsTrue(resultsMapping.ContainsKey("ObjectValidatorAttributeFixtureTestClass-Property"));
            Assert.AreEqual("Property", resultsMapping["ObjectValidatorAttributeFixtureTestClass-Property"].Key);
            Assert.AreEqual(null, resultsMapping["ObjectValidatorAttributeFixtureTestClass-Property"].Tag);
            Assert.AreSame(target, resultsMapping["ObjectValidatorAttributeFixtureTestClass-Property"].Target);
        }
        public void AttributeWithNullRulesetCannotBeUsedAsValidationAttribute()
        {
            ValidationAttribute attribute = new ObjectValidatorAttribute();

            try
            {
                attribute.IsValid("");
                Assert.Fail("should have thrown");
            }
            catch (NotSupportedException)
            {
            }
        }
        public void AttributeWithNonNullRulesetReturnsValid()
        {
            ValidationAttribute attribute = new ObjectValidatorAttribute() { Ruleset = "some ruleset" };

            Assert.IsTrue(attribute.IsValid(""));
        }