Exemplo n.º 1
0
        public void GivenTypesThatInheritFromTypedPageData_ValidatePageTypeDefinitions_DoesNotThrowException()
        {
            List <PageTypeDefinition> definitions         = new List <PageTypeDefinition>();
            PageTypeDefinition        validTypeDefinition = new PageTypeDefinition
            {
                Type      = typeof(TypedPageData),
                Attribute = new PageTypeAttribute()
            };

            definitions.Add(validTypeDefinition);
            PageTypeDefinitionValidator definitionValidator = new PageTypeDefinitionValidator(null);

            definitionValidator.ValidatePageTypeDefinitions(definitions);
        }
Exemplo n.º 2
0
        public void GivenTwoPageTypesWithSameNameAndNoGuid_ValidatePageTypeDefinitions_ThrowsException()
        {
            List <PageTypeDefinition> definitions         = new List <PageTypeDefinition>();
            PageTypeDefinition        validTypeDefinition = new PageTypeDefinition
            {
                Type      = typeof(TypedPageData),
                Attribute = new PageTypeAttribute()
            };

            definitions.Add(validTypeDefinition);
            definitions.Add(validTypeDefinition);
            PageTypeDefinitionValidator definitionValidator = new PageTypeDefinitionValidator(null);

            Exception exception = Record.Exception(() => definitionValidator.ValidatePageTypeDefinitions(definitions));

            Assert.NotNull(exception);
        }
Exemplo n.º 3
0
        public void GivenListOfPageTypeDefinitions_ValidatePageTypeDefinitions_ValidatesEachPageType()
        {
            MockRepository            fakes       = new MockRepository();
            List <PageTypeDefinition> definitions = new List <PageTypeDefinition>();
            PageTypeDefinition        definition  = new PageTypeDefinition
            {
                Type      = typeof(TypedPageData),
                Attribute = new PageTypeAttribute()
            };

            definitions.Add(definition);
            PageTypeDefinitionValidator definitionValidator = fakes.PartialMock <PageTypeDefinitionValidator>((PageDefinitionTypeMapper)null);

            definitionValidator.Stub(validator => validator.ValidatePageTypeDefinition(definition, definitions));
            definitionValidator.Replay();

            definitionValidator.ValidatePageTypeDefinitions(definitions);

            definitionValidator.AssertWasCalled(validator => validator.ValidatePageTypeDefinition(definition, definitions));
        }
Exemplo n.º 4
0
        public void GivenDefinitionWithTypeThatDoesNotInheritFromTypedPageData_ValidatePageTypeDefinitions_ThrowsException()
        {
            List <PageTypeDefinition> definitions           = new List <PageTypeDefinition>();
            PageTypeDefinition        invalidTypeDefinition = new PageTypeDefinition
            {
                Type      = typeof(PageData),
                Attribute = new PageTypeAttribute()
            };

            definitions.Add(invalidTypeDefinition);
            PageTypeDefinitionValidator definitionValidator = new PageTypeDefinitionValidator(null);

            Exception exception =
                Record.Exception(
                    () => definitionValidator.ValidatePageTypeDefinitions(definitions));

            Assert.NotNull(exception);
            Type exceptionType = exception.GetType();

            Assert.Equal <Type>(typeof(PageTypeBuilderException), exceptionType);
        }
Exemplo n.º 5
0
        public void GivenDefinitionNameLongerThan50Chars_ValidatePageTypeDefinitions_ThrowsException()
        {
            List <PageTypeDefinition> definitions           = new List <PageTypeDefinition>();
            PageTypeDefinition        invalidTypeDefinition = new PageTypeDefinition
            {
                Type      = typeof(TypedPageData),
                Attribute = new PageTypeAttribute()
                {
                    Name = "123456789123456789123456789123456789123456789123456"
                }
            };

            definitions.Add(invalidTypeDefinition);
            PageTypeDefinitionValidator definitionValidator = new PageTypeDefinitionValidator(null);

            Exception exception =
                Record.Exception(
                    () => definitionValidator.ValidatePageTypeDefinitions(definitions));

            Assert.NotNull(exception);
            Type exceptionType = exception.GetType();

            Assert.Equal <Type>(typeof(PageTypeBuilderException), exceptionType);
        }
Exemplo n.º 6
0
 protected internal virtual void ValidatePageTypeDefinitions(IEnumerable <PageTypeDefinition> pageTypeDefinitions)
 {
     PageTypeDefinitionValidator.ValidatePageTypeDefinitions(pageTypeDefinitions);
 }