public void CreatedInstanceReturnsCorrectValuesOnImplementedInterfaces()
        {
            MetadataValidatedType validatedType
                = new MetadataValidatedType(typeof(MetadataValidatedTypeFixtureTestClass), "");

            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass), ((IValidatedType)validatedType).MemberInfo);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass), ((IValidatedType)validatedType).TargetType);
            Assert.AreEqual(CompositionType.And, ((IValidatedType)validatedType).CompositionType);
            Assert.AreEqual(false, ((IValidatedType)validatedType).IgnoreNulls);
        }
        public void CreatedInstanceReturnsCorrectValuesOnImplementedInterfaces()
        {
            MetadataValidatedType validatedType
                = new MetadataValidatedType(typeof(MetadataValidatedTypeFixtureTestClass), "");

            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass), ((IValidatedType)validatedType).MemberInfo);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass), ((IValidatedType)validatedType).TargetType);
            Assert.AreEqual(CompositionType.And, ((IValidatedType)validatedType).CompositionType);
            Assert.AreEqual(false, ((IValidatedType)validatedType).IgnoreNulls);
        }
        public void ValidatedFieldsEnumerableIncludesPublicFieldsOnly()
        {
            MetadataValidatedType validatedType
                = new MetadataValidatedType(typeof(MetadataValidatedTypeFixtureTestClass), "");
            IEnumerable<IValidatedElement> validatedFields
                = ((IValidatedType)validatedType).GetValidatedFields();

            IDictionary<string, MemberInfo> validatedElementsMapping
                = CollectValidatedElements(validatedFields);

            Assert.AreEqual(5, validatedElementsMapping.Count);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetField("InheritedPublicField"),
                           validatedElementsMapping["InheritedPublicField"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetField("PublicFieldWithoutValidators"),
                           validatedElementsMapping["PublicFieldWithoutValidators"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetField("PublicField"),
                           validatedElementsMapping["PublicField"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetField("SecondPublicField"),
                           validatedElementsMapping["SecondPublicField"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetField("PublicFieldWithValidatorsForRuleset"),
                           validatedElementsMapping["PublicFieldWithValidatorsForRuleset"]);
        }
        public void ValidatedMethodsEnumerableIncludesPublicMethodsOnly()
        {
            MetadataValidatedType validatedType
                = new MetadataValidatedType(typeof(MetadataValidatedTypeFixtureTestClass), "");
            IEnumerable <IValidatedElement> validatedMethods
                = ((IValidatedType)validatedType).GetValidatedMethods();

            IDictionary <string, MemberInfo> validatedElementsMapping
                = CollectValidatedElements(validatedMethods);

            Assert.AreEqual(13, validatedElementsMapping.Count);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetMethod("InheritedPublicMethod"),
                           validatedElementsMapping["InheritedPublicMethod"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetMethod("PublicMethodWithoutValidators"),
                           validatedElementsMapping["PublicMethodWithoutValidators"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetMethod("PublicMethod"),
                           validatedElementsMapping["PublicMethod"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetMethod("SecondPublicMethod"),
                           validatedElementsMapping["SecondPublicMethod"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetMethod("PublicMethodWithValidatorsForRuleset"),
                           validatedElementsMapping["PublicMethodWithValidatorsForRuleset"]);
        }
        public void ValidatedPropertiesEnumerableIncludesNonIndexedReadablePublicPropertiesOnly()
        {
            MetadataValidatedType validatedType
                = new MetadataValidatedType(typeof(MetadataValidatedTypeFixtureTestClass), "");

            IEnumerable <IValidatedElement> validatedProperties
                = ((IValidatedType)validatedType).GetValidatedProperties();
            IDictionary <string, MemberInfo> validatedElementsMapping
                = CollectValidatedElements(validatedProperties);

            Assert.AreEqual(5, validatedElementsMapping.Count);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetProperty("InheritedPublicProperty"),
                           validatedElementsMapping["InheritedPublicProperty"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetProperty("PublicPropertyWithoutValidators"),
                           validatedElementsMapping["PublicPropertyWithoutValidators"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetProperty("PublicProperty"),
                           validatedElementsMapping["PublicProperty"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetProperty("SecondPublicProperty"),
                           validatedElementsMapping["SecondPublicProperty"]);
            Assert.AreSame(typeof(MetadataValidatedTypeFixtureTestClass).GetProperty("PublicPropertyWithValidatorsForRuleset"),
                           validatedElementsMapping["PublicPropertyWithValidatorsForRuleset"]);
        }