Example #1
0
        public void GetAttributesForType_PropertyAttributes_IsNull()
        {
            // Arrange & Act
            var attributes = ModelAttributes.GetAttributesForType(typeof(BaseViewModel));

            // Assert
            Assert.Null(attributes.PropertyAttributes);
        }
        public void GetAttributesForType_IncludesMetadataAttributes()
        {
            // Arrange & Act
            var attributes = ModelAttributes.GetAttributesForType(typeof(BaseViewModel));

            // Assert
            Assert.Single(attributes.OfType <ClassValidator>());
        }
Example #3
0
        private TModelMetadata CreateTypeInformation(Type type, IEnumerable <Attribute> associatedAttributes)
        {
            var attributes = ModelAttributes.GetAttributesForType(type);

            if (associatedAttributes != null)
            {
                attributes = attributes.Concat(associatedAttributes);
            }

            return(CreateMetadataPrototype(attributes, containerType: null, modelType: type, propertyName: null));
        }
        private IEnumerable <IModelValidator> GetValidatorsForType(ModelMetadata metadata)
        {
            var attributes = ModelAttributes.GetAttributesForType(metadata.ModelType);

            return(GetValidators(metadata, attributes));
        }