public void Constructor_SetsPropertiesValidtorProperty()
        {
            PageDefinitionTypeMapper mapper = new PageDefinitionTypeMapper(null);

            PageTypeDefinitionPropertiesValidator validator = new PageTypeDefinitionPropertiesValidator(mapper);

            Assert.NotNull(validator.PageDefinitionTypeMapper);
        }
예제 #2
0
 public PageTypeDefinitionValidator(PageDefinitionTypeMapper pageDefinitionTypeMapper)
 {
     PropertiesValidator = new PageTypeDefinitionPropertiesValidator(pageDefinitionTypeMapper);
 }
        public void GivenVirtualCompilerGeneratedProperty_ValidateCompilerGeneratedProperty_DoesNotThrowsException()
        {
            PropertyInfo nonVirtualCompilerGeneratedProperty = typeof(TestPageType).GetProperty("CompilerGeneratedProperty");
            PageTypeDefinitionPropertiesValidator propertiesValidator = new PageTypeDefinitionPropertiesValidator(null);


            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidateCompilerGeneratedProperty(nonVirtualCompilerGeneratedProperty);
            });

            Assert.Null(exception);
        }
        public void GivenAttributeWithMappableTypeAndUnmappableTypeSpecified_ValidatePageTypePropertyType_ThrowsException()
        {
            PropertyInfo propertyInfo = typeof(TestPageType).GetProperty("PropertyWithInvalidTypeSpecified");
            PageTypePropertyAttribute attribute = propertyInfo.GetCustomAttributes<PageTypePropertyAttribute>().First();
            MockRepository fakes = new MockRepository();
            PageDefinitionTypeRepository pageDefinitionTypeRepository = fakes.Stub<PageDefinitionTypeRepository>();
            pageDefinitionTypeRepository.Stub(factory =>
                factory.GetPageDefinitionType("System.Text.StringBuilder", "mscorlib")).Return(null);
            pageDefinitionTypeRepository.Replay();
            PageTypeDefinitionPropertiesValidator propertiesValidator =
                new PageTypeDefinitionPropertiesValidator(new PageDefinitionTypeMapper(pageDefinitionTypeRepository, new NativePageDefinitionsMap()));


            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidatePageTypePropertyType(propertyInfo);
            });

            Assert.NotNull(exception);
            Assert.Equal<Type>(typeof(UnmappablePropertyTypeException), exception.GetType());
        }
        public void GivenAttributeWithMappableTypeSpecified_ValidatePageTypePropertyType_DoesNotThrowException()
        {
            PropertyInfo propertyInfo = typeof(TestPageType).GetProperty("PropertyWithValidTypeSpecified");
            PageTypePropertyAttribute attribute = propertyInfo.GetCustomAttributes<PageTypePropertyAttribute>().First();
            MockRepository fakes = new MockRepository();
            PageDefinitionTypeRepository pageDefinitionTypeRepository = fakes.Stub<PageDefinitionTypeRepository>();
            pageDefinitionTypeRepository.Stub(factory =>
                factory.GetPageDefinitionType("EPiServer.SpecializedProperties.PropertyXhtmlString", "EPiServer")).Return(new PageDefinitionType());
            pageDefinitionTypeRepository.Replay();
            PageTypeDefinitionPropertiesValidator propertiesValidator =
                new PageTypeDefinitionPropertiesValidator(new PageDefinitionTypeMapper(pageDefinitionTypeRepository, new NativePageDefinitionsMap()));

            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidatePageTypePropertyType(propertyInfo);
            });

            Assert.Null(exception);
        }
        public void GivenAttributeWithNoTypeSpecifiedAndOfUnmappableType_ValidatePageTypePropertyType_ThrowsException()
        {
            PropertyInfo propertyInfo = typeof(TestPageType).GetProperty("PropertyWithInvalidTypeAndNoTypeSpecified");
            PageTypePropertyAttribute attribute = propertyInfo.GetCustomAttributes<PageTypePropertyAttribute>().First();
            PageTypeDefinitionPropertiesValidator propertiesValidator = new PageTypeDefinitionPropertiesValidator(new PageDefinitionTypeMapper(null, new NativePageDefinitionsMap()));

            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidatePageTypePropertyType(propertyInfo);
            });

            Assert.NotNull(exception);
            Assert.Equal<Type>(typeof(UnmappablePropertyTypeException), exception.GetType());
        }
        public void GivenAttributeWithTabPropertySetToAbstractSubClassOfTab_ValidatePageTypeAttributeTabProperty_ThrowsException()
        {
            PropertyInfo propertyInfo = typeof(TestPageType).GetProperty("PropertyWithTabSetAbstractTabSubClass");
            PageTypePropertyAttribute attribute = propertyInfo.GetCustomAttributes<PageTypePropertyAttribute>().First();
            PageTypeDefinitionPropertiesValidator propertiesValidator = new PageTypeDefinitionPropertiesValidator(null);


            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidatePageTypeAttributeTabProperty(propertyInfo, attribute);
            });

            Assert.NotNull(exception);
        }
        public void GivenAttributeWithValidTabProperty_ValidatePageTypeAttributeTabProperty_DoesNotThrowException()
        {
            PropertyInfo propertyInfo = typeof(TestPageType).GetProperty("PropertyWithValidTab");
            PageTypePropertyAttribute attribute = propertyInfo.GetCustomAttributes<PageTypePropertyAttribute>().First();
            PageTypeDefinitionPropertiesValidator propertiesValidator = new PageTypeDefinitionPropertiesValidator(null);


            Exception exception = Record.Exception(() =>
            {
                propertiesValidator.ValidatePageTypeAttributeTabProperty(propertyInfo, attribute);
            });

            Assert.Null(exception);
        }
 public PageTypeDefinitionValidator(PageDefinitionTypeMapper pageDefinitionTypeMapper)
 {
     PropertiesValidator = new PageTypeDefinitionPropertiesValidator(pageDefinitionTypeMapper);
 }