Beispiel #1
0
        public void Can_Retrieve_ContentTypes_After_Resolving()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var modelType          = typeof(Home);
            var contentType        = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);
            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes();

            Assert.That(mappedContentTypes, Is.Not.Null);
            Assert.That(mappedContentTypes.Any(), Is.True);
            Assert.That(mappedContentTypes.Count(), Is.EqualTo(2));
        }
Beispiel #2
0
        public void Can_Resolve_ContentType_From_Decorated_ContentPage_Model()
        {
            var modelType   = typeof(ContentPage);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups.Any(), Is.True);
            Assert.That(contentType.Value.PropertyGroups.Count(), Is.EqualTo(1));
            Assert.That(contentType.Value.PropertyTypes.Any(), Is.True);
            Assert.That(contentType.Value.PropertyTypes.Count(), Is.EqualTo(1));
        }
Beispiel #3
0
        public void Can_Resolve_Full_List_Of_Models_Implementing_ContentTypeBase()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var foundTypes      = PluginManager.Current.ResolveContentTypeBaseTypes();
            var contentTypeList = foundTypes.Select(ContentTypeDefinitionFactory.GetContentTypeDefinition).ToList();

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes();

            Assert.That(contentTypeList.Count(), Is.EqualTo(mappedContentTypes.Count()));

            ServiceContext.ContentTypeService.Save(mappedContentTypes);//Save to db
        }
Beispiel #4
0
        public void Can_Save_Models_To_Database()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var homeModel           = typeof(Home);
            var textPageModel       = typeof(TextPage);
            var homeContentType     = ContentTypeDefinitionFactory.GetContentTypeDefinition(homeModel);
            var textPageContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(textPageModel);

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();

            ServiceContext.ContentTypeService.Save(mappedContentTypes);
        }
Beispiel #5
0
        public void Can_Resolve_Existing_ContentType_With_Decorated_Model()
        {
            var textPage = MockedContentTypes.CreateTextpageContentType();

            ServiceContext.ContentTypeService.Save(textPage);

            var modelType   = typeof(TextPage);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType.Value.Id, Is.EqualTo(textPage.Id));

            ServiceContext.ContentTypeService.Save(contentType.Value);
        }
Beispiel #6
0
        public void Can_Resolve_ContentType_From_Decorated_Home_Model()
        {
            var modelType   = typeof(Home);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups, Is.Not.Null);
            Assert.That(contentType.Value.PropertyTypes.Any(), Is.True);
            Assert.That(contentType.Value.PropertyTypes.Count(), Is.EqualTo(2));

            var result = SerializationService.ToStream(contentType.Value);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Beispiel #7
0
        public void Can_Create_Model_With_NonExisting_DataTypeDefinition()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var modelType   = typeof(ModelWithNewDataType);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes();

            ServiceContext.ContentTypeService.Save(mappedContentTypes);

            var model = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 1);

            Assert.That(model, Is.Not.Null);
        }
Beispiel #8
0
        public void Can_Resolve_ContentType_From_PlainPocoType_Model()
        {
            var modelType   = typeof(PlainPocoType);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups, Is.Not.Null);
            Assert.That(contentType.Value.PropertyTypes.Any(), Is.True);
            Assert.That(contentType.Value.PropertyGroups.Count(), Is.EqualTo(1));
            Assert.That(contentType.Value.PropertyTypes.Count(), Is.EqualTo(5));

            var result = SerializationService.ToStream(contentType.Value);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Beispiel #9
0
        public void Can_Resolve_And_Save_Decorated_Model_To_Database()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var model            = typeof(DecoratedModelPage);
            var modelContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(model);

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();

            ServiceContext.ContentTypeService.Save(mappedContentTypes);

            var type1 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 2);

            Assert.That(type1, Is.Not.Null);
            Assert.That(type1.PropertyGroups.Count(), Is.EqualTo(2));
            Assert.That(type1.PropertyTypes.Count(), Is.EqualTo(4));
        }
Beispiel #10
0
        public void Can_Resolve_ContentType_Composition_And_Save_To_Database()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var metaSeoModel    = typeof(MetaSeo);
            var seoContentType  = ContentTypeDefinitionFactory.GetContentTypeDefinition(metaSeoModel);
            var metaModel       = typeof(Meta);
            var metaContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(metaModel);
            var baseModel       = typeof(Base);
            var baseContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(baseModel);
            var newsModel       = typeof(News);
            var newsContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(newsModel);

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();

            ServiceContext.ContentTypeService.Save(mappedContentTypes);

            Assert.That(mappedContentTypes.Count(), Is.EqualTo(4));
        }
Beispiel #11
0
        public void Can_Resolve_Parent_Child_ContentTypes_And_Save_To_Database()
        {
            ContentTypeDefinitionFactory.ClearContentTypeCache();

            var simplemodel  = typeof(SimpleContentPage);
            var model        = typeof(AdvancedContentPage);
            var sContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(simplemodel);
            var aContentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(model);

            var mappedContentTypes = ContentTypeDefinitionFactory.RetrieveMappedContentTypes().ToList();

            ServiceContext.ContentTypeService.Save(mappedContentTypes);

            var type1 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed);
            var type2 = ServiceContext.ContentTypeService.GetContentType(NodeDto.NodeIdSeed + 1);

            Assert.That(type1, Is.Not.Null);
            Assert.That(type2, Is.Not.Null);
        }