public void AddNoNativeRegions_Success()
        {
            const string regionShemaTitle = "AddNoNativeRegions_Success";
            Schema       regionSchema     = null;

            try
            {
                //init engine
                Component inputItem = (Component)TestSession.GetObject(CoreCoponentWebDavUrl);

                // Create TestData Regions
                Publication testPublication = (Publication)inputItem.ContextRepository;

                regionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = regionShemaTitle,
                    Description = regionShemaTitle
                };
                regionSchema.Save(true);

                RenderedItem testRenderedItem;
                Package      testPackage    = RunTemplate(typeof(PublishMappings), inputItem, out testRenderedItem);
                Item         testItem       = testPackage.GetByName("/Preview/system/mappings/regions.json");
                string       content        = testItem.GetAsString();
                var          definedRegions = JsonConvert.DeserializeObject <List <RegionDefinitionTest> >(content);
                Assert.IsFalse(definedRegions.Any(x => x.Region == regionShemaTitle),
                               "No TCM Region added to Regions.json");
            }
            finally
            {
                //Cleanup
                regionSchema?.Delete();
            }
        }
        public void CreatePageModel_MediaManager_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.MediaManagerPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData     mainRegion      = GetMainRegion(pageModel);
            EntityModelData     mmItem          = mainRegion.Entities[0];
            BinaryContentData   binaryContent   = mmItem.BinaryContent;
            ExternalContentData externalContent = mmItem.ExternalContent;

            Assert.IsNotNull(binaryContent, "binaryContent");
            Assert.AreEqual("https://mmecl.dist.sdlmedia.com/distributions/?o=51498399-31e9-4c89-98eb-0c4256c96f71", binaryContent.Url, "binaryContent.Url");
            Assert.AreEqual("application/externalcontentlibrary", binaryContent.MimeType, "binaryContent.MimeType");
            Assert.IsNotNull(externalContent, "externalContent");
            Assert.AreEqual("ecl:1065-mm-415-dist-file", externalContent.Id, "externalContent.Id");
            Assert.AreEqual("html5dist", externalContent.DisplayTypeId, "externalContent.DisplayTypeId");
            Assert.IsNotNull(externalContent.Metadata, "externalContent.Metadata");
            object globalId;

            Assert.IsTrue(externalContent.Metadata.TryGetValue("GlobalId", out globalId), "externalContent.Metadata['GlobalId']");
            Assert.AreEqual("51498399-31e9-4c89-98eb-0c4256c96f71", globalId, "globalId");
            StringAssert.Contains(externalContent.TemplateFragment, (string)globalId, "externalContent.TemplateFragment");
        }
        public void CreatePageModel_ExampleSiteHomePage_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ExampleSiteHomePageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            Assert.IsNotNull(pageModel.MvcData, "pageModel.MvcData");
            Assert.IsNull(pageModel.HtmlClasses, "pageModel.HtmlClasses");
            Assert.IsNotNull(pageModel.XpmMetadata, "pageModel.XpmMetadata");
            Assert.IsNull(pageModel.ExtensionData, "pageModel.ExtensionData");
            Assert.AreEqual("10015", pageModel.SchemaId, "pageModel.SchemaId");
            Assert.IsNotNull(pageModel.Metadata, "pageModel.Metadata");
            Assert.AreEqual("640", pageModel.Id, "pageModel.Id");
            Assert.AreEqual("Home", pageModel.Title, "pageModel.Title");
            Assert.AreEqual("/index", pageModel.UrlPath, "pageModel.UrlPath");
            Assert.IsNotNull(pageModel.Meta, "pageModel.Meta");
            Assert.AreEqual(7, pageModel.Meta.Count, "pageModel.Meta.Count");
            Assert.IsNotNull(pageModel.Regions, "pageModel.Regions");
            Assert.AreEqual(5, pageModel.Regions.Count, "pageModel.Regions.Count");
            AssertExpectedIncludePageRegions(pageModel.Regions, new [] { "Header", "Footer" });

            KeywordModelData sitemapKeyword = (KeywordModelData)pageModel.Metadata["sitemapKeyword"];

            AssertNotExpanded(sitemapKeyword, false, "sitemapKeyword"); // Keyword Should not be expanded because Category is publishable

            Assert.IsNotNull(testRenderedItem, "testRenderedItem");
            Assert.AreEqual(5, testRenderedItem.Binaries.Count, "testRenderedItem.Binaries.Count");
            Assert.AreEqual(5, testRenderedItem.ChildRenderedItems.Count, "testRenderedItem.ChildRenderedItems.Count");
        }
        public void CreatePageModel_KeywordModel_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi811PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            Assert.IsNotNull(pageModel.SchemaId, "pageModel.SchemaId");

            ContentModelData pageMetadata = pageModel.Metadata;

            Assert.IsNotNull(pageMetadata, "pageMetadata");
            KeywordModelData pageKeyword = pageMetadata["pageKeyword"] as KeywordModelData;

            Assert.IsNotNull(pageKeyword, "pageKeyword");
            Assert.AreEqual("10120", pageKeyword.Id, "pageKeyword.Id");
            Assert.AreEqual("Test Keyword 2", pageKeyword.Title, "pageKeyword.Title");
            ContentModelData keywordMetadata = pageKeyword.Metadata;

            Assert.IsNotNull(keywordMetadata, "keywordMetadata");
            Assert.AreEqual("This is textField of Test Keyword 2", keywordMetadata["textField"], "keywordMetadata['textField']");
            Assert.AreEqual("999.99", keywordMetadata["numberField"], "keywordMetadata['numberField']");
            KeywordModelData keywordField = keywordMetadata["keywordField"] as KeywordModelData;

            Assert.IsNotNull(keywordField, "keywordField");
        }
        public void CreatePageModel_RichTextEmbeddedMediaManagerItems_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi2306PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData mainRegion = GetMainRegion(pageModel);
            EntityModelData article    = mainRegion.Entities.LastOrDefault(e => e.MvcData.ViewName == "Article");

            Assert.IsNotNull(article, "article");

            ContentModelData[] articleBody = (ContentModelData[])article.Content["articleBody"];
            RichTextData       content     = (RichTextData)articleBody[0]["content"];
            EntityModelData    embeddedMediaManagerItem = content.Fragments.OfType <EntityModelData>().FirstOrDefault();

            Assert.IsNotNull(embeddedMediaManagerItem, "embeddedMediaManagerItem");

            OutputJson(embeddedMediaManagerItem);

            BinaryContentData   binaryContent   = embeddedMediaManagerItem.BinaryContent;
            ExternalContentData externalContent = embeddedMediaManagerItem.ExternalContent;

            Assert.IsNotNull(binaryContent, "binaryContent");
            Assert.IsNotNull(externalContent, "externalContent");
            Assert.AreEqual("https://mmecl.dist.sdlmedia.com/distributions/?o=3e5f81f2-c7b3-47f7-8ede-b84b447195b9", binaryContent.Url, "binaryContent.Url");
            Assert.AreEqual("1065-mm-204-dist-file.ecl", binaryContent.FileName, "binaryContent.FileName");
            Assert.AreEqual("application/externalcontentlibrary", binaryContent.MimeType, "binaryContent.MimeType");
            Assert.AreEqual("ecl:1065-mm-204-dist-file", externalContent.Id, "ecl:1065-mm-204-dist-file");
            Assert.AreEqual("html5dist", externalContent.DisplayTypeId, "externalContent.DisplayTypeId");
            Assert.IsNotNull(externalContent.Metadata, "externalContent.Metadata");
        }
        public void CreatePageModel_HybridRegion_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.R2PageIncludesPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            AssertExpectedIncludePageRegions(pageModel.Regions, new [] { "Header" }, allowEntities: true);

            // Header (Include Page) Region should also contain an Entity Model for the Test CP.
            RegionModelData header = pageModel.Regions.First(r => r.Name == "Header");

            Assert.IsNotNull(header.Entities, "header.Entities");
            Assert.AreEqual(1, header.Entities.Count, "header.Entities.Count");
            EntityModelData testEntity = header.Entities[0];

            MvcData mvcData = testEntity.MvcData;

            Assert.IsNotNull(mvcData, "mvcData");
            Assert.IsNotNull(mvcData.Parameters, "mvcData.Parameters");
            Assert.AreEqual(2, mvcData.Parameters.Count, "mvcData.Parameters.Count");
            string name;

            Assert.IsTrue(mvcData.Parameters.TryGetValue("name", out name), "mvcData.Parameters['name']");
            Assert.AreEqual("value", name, "name");
        }
        public void CreatePageModel_ComponentLinkExpansion_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ComponentLinkTestPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData mainRegion = GetMainRegion(pageModel);
            EntityModelData testEntity = mainRegion.Entities[0];

            Assert.IsNotNull(testEntity, "testEntity");
            Assert.IsNotNull(testEntity.Content, "testEntity.Content");
            EntityModelData[] compLinkField = (EntityModelData[])testEntity.Content["compLink"];
            Assert.AreEqual(4, compLinkField.Length, "compLinkField.Length");

            EntityModelData notExpandedCompLink = compLinkField[0]; // Has Data Presentation

            Assert.IsNotNull(notExpandedCompLink, "notExpandedCompLink");
            Assert.AreEqual("9712-10247", notExpandedCompLink.Id, "notExpandedCompLink.Id");
            Assert.IsNull(notExpandedCompLink.SchemaId, "notExpandedCompLink.SchemaId");
            Assert.IsNull(notExpandedCompLink.Content, "notExpandedCompLink.Content");

            EntityModelData expandedCompLink = compLinkField[1]; // Has no Data Presentation

            Assert.IsNotNull(expandedCompLink, "expandedCompLink");
            Assert.AreEqual("9710", expandedCompLink.Id, "expandedCompLink.Id");
            Assert.AreEqual("9709", expandedCompLink.SchemaId, "9710");
            Assert.IsNotNull(expandedCompLink.Content, "expandedCompLink.Content");
        }
        public void CreatePageModel_DuplicatePredefinedRegions_Exception()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.PredefinedRegionsTestPageWebDavUrl);

            RenderedItem testRenderedItem;

            AssertThrowsException <DxaException>(() => CreatePageModel(testPage, out testRenderedItem));
        }
        public void CreatePageModel_Tsi1308_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi1308PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            // TODO TSI-132: further assertions
        }
        public void AddNotUniqueRegions_Success()
        {
            const string regionShemaTitle             = "AddNotUniqueRegions_Success1";
            const string nestedRegionSchemaTitle      = "AddNotUniqueRegions_Success2";
            const string superNestedRegionSchemaTitle = "AddNotUniqueRegions_Success3";
            Schema       regionSchema            = null;
            Schema       nestedRegionSchema      = null;
            Schema       superNestedRegionSchema = null;

            try
            {
                //init engine
                Component inputItem = (Component)TestSession.GetObject(CoreCoponentWebDavUrl);

                // Create TestData Regions
                Publication testPublication = (Publication)inputItem.ContextRepository;

                superNestedRegionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = superNestedRegionSchemaTitle,
                    Description = superNestedRegionSchemaTitle
                };
                superNestedRegionSchema.Save(true);

                nestedRegionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = nestedRegionSchemaTitle,
                    Description = nestedRegionSchemaTitle
                };
                SaveRegionSchemaWithRegionList(nestedRegionSchema, new object[] { regionShemaTitle, superNestedRegionSchema, true });

                regionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = regionShemaTitle,
                    Description = regionShemaTitle
                };
                SaveRegionSchemaWithRegionList(regionSchema, new object[] { regionShemaTitle, nestedRegionSchema, true });

                RenderedItem testRenderedItem;
                Package      testPackage    = RunTemplate(typeof(PublishMappings), inputItem, out testRenderedItem);
                Item         testItem       = testPackage.GetByName(RegionJsonFile);
                string       content        = testItem.GetAsString();
                var          definedRegions = JsonConvert.DeserializeObject <List <RegionDefinitionTest> >(content);
                Assert.IsTrue(definedRegions.Count(x => x.Region == regionShemaTitle) == 1,
                              "Despite Different Schemas has Regions with the same name only one of those added to Regions.json");
            }
            finally
            {
                //Cleanup
                regionSchema?.Delete();
                nestedRegionSchema?.Delete();
                superNestedRegionSchema?.Delete();
            }
        }
Пример #11
0
        public void GetCulture_WithLocalizationConfigComponent_Success()
        {
            Publication  testPublication = (Publication)TestSession.GetObject(TestFixture.AutoTestParentWebDavUrl);
            TestTemplate testTemplate    = new TestTemplate(testPublication);

            string locale = testTemplate.TestGetLocale();

            Assert.AreEqual("en-US", locale);
        }
        public void CreatePageModel_InternationalizedUrlPath_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi1278PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            Assert.AreEqual("/autotest-parent/tsi-1278_trådløst", pageModel.UrlPath, "pageModel.UrlPath");
        }
        public void CreatePageModel_Article_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ArticlePageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            // First assert the Page Model itself looks OK
            Assert.IsNotNull(pageModel.MvcData, "pageModel.MvcData");
            Assert.IsNull(pageModel.HtmlClasses, "pageModel.HtmlClasses");
            Assert.IsNotNull(pageModel.XpmMetadata, "pageModel.XpmMetadata");
            Assert.IsNull(pageModel.ExtensionData, "pageModel.ExtensionData");
            Assert.IsNull(pageModel.SchemaId, "pageModel.SchemaId");
            Assert.IsNull(pageModel.Metadata, "pageModel.Metadata");
            Assert.AreEqual("9786", pageModel.Id, "pageModel.Id");
            Assert.AreEqual("Test Article used for Automated Testing (Sdl.Web.Tridion.Tests)", pageModel.Title, "pageModel.Title");
            Assert.AreEqual("/autotest-parent/test_article_page", pageModel.UrlPath, "pageModel.UrlPath");
            Assert.IsNotNull(pageModel.Meta, "pageModel.Meta");
            Assert.AreEqual(5, pageModel.Meta.Count, "pageModel.Meta.Count");
            Assert.IsNotNull(pageModel.Regions, "pageModel.Regions");
            Assert.AreEqual(4, pageModel.Regions.Count, "pageModel.Regions.Count");
            AssertExpectedIncludePageRegions(pageModel.Regions, new[] { "Header", "Footer", "Content Tools" });

            // Assert the output RenderedItem looks OK
            Assert.IsNotNull(testRenderedItem, "testRenderedItem");
            Assert.AreEqual(2, testRenderedItem.Binaries.Count, "testRenderedItem.Binaries.Count");
            Assert.AreEqual(1, testRenderedItem.ChildRenderedItems.Count, "testRenderedItem.ChildRenderedItems.Count");

            // Assert the Article EntityModelData looks OK
            RegionModelData mainRegion = GetMainRegion(pageModel);
            EntityModelData article    = mainRegion.Entities[0];

            AssertExpanded(article, true, "article");
            StringAssert.Matches(article.Id, new Regex(@"\d+"));

            ContentModelData articleBody = (ContentModelData)article.Content["articleBody"];
            RichTextData     content     = (RichTextData)articleBody["content"];

            Assert.IsNotNull(content, "content");
            Assert.IsNotNull(content.Fragments, "content.Fragments");

            // Embedded image in Rich Text field should be represented as an embedded EntityModelData
            Assert.AreEqual(3, content.Fragments.Count, "content.Fragments.Count");
            EntityModelData image = content.Fragments.OfType <EntityModelData>().FirstOrDefault();

            Assert.IsNotNull(image, "image");
            Assert.IsNotNull(image.BinaryContent, "image.BinaryContent");
            Assert.AreEqual("image/jpeg", image.BinaryContent.MimeType, "image.BinaryContent.MimeType");

            // Image should have "altText" metadata field obtained from the original XHTML; see TSI-2289.
            Assert.IsNotNull(image.Metadata, "image.Metadata");
            object altText;

            Assert.IsTrue(image.Metadata.TryGetValue("altText", out altText));
            Assert.AreEqual("calculator", altText, "altText");
        }
        public void CreateEntityModel_WithoutComponentTemplate_Success()
        {
            string[]  articleDcpIds = TestFixture.ArticleDcpId.Split('/');
            Component article       = (Component)TestSession.GetObject(articleDcpIds[0]);

            RenderedItem    testRenderedItem;
            EntityModelData entityModel = CreateEntityModel(article, null, out testRenderedItem);

            // TODO TSI-132: further assertions
        }
Пример #15
0
        private List <RegionDefinitionTest> GetRenderedRegionDefinitions()
        {
            Component    inputItem = (Component)TestSession.GetObject(CoreComponentWebDavUrl);
            RenderedItem testRenderedItem;
            Package      testPackage = RunTemplate(typeof(PublishMappings), inputItem, out testRenderedItem);
            Item         testItem    = testPackage.GetByName("/Preview/system/mappings/regions.json");
            var          content     = testItem.GetAsString();
            List <RegionDefinitionTest> definedRegions = JsonConvert.DeserializeObject <List <RegionDefinitionTest> >(content);

            return(definedRegions);
        }
        public void CreateEntityModel_WithCategoryLink_Success()
        {
            Component testComponent = (Component)TestSession.GetObject(TestFixture.TestComponentWebDavUrl);

            RenderedItem    testRenderedItem;
            EntityModelData testEntity = CreateEntityModel(testComponent, null, out testRenderedItem);

            string[] externalLinkField = (string[])testEntity.Content["ExternalLink"];
            Assert.AreEqual(2, externalLinkField.Length, "externalLinkField.Length");
            Assert.AreEqual("http://www.sdl.com", externalLinkField[0], "externalLinkField[0]");
            Assert.AreEqual("tcm:1065-2702-512", externalLinkField[1], "externalLinkField[1]"); // NOTE: This is a (managed) Category link (!)
        }
        public void CreatePageModel_ArticleDcp_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ArticleDcpPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData mainRegion = GetMainRegion(pageModel);
            EntityModelData article    = mainRegion.Entities[0];

            AssertNotExpanded(article, "article");
        }
        public void AddNativeRegionUniqueName_Success()
        {
            const string regionShemaTitle        = "AddNativeRegionUniqueName_Success1";
            const string nestedRegionSchemaTitle = "AddNativeRegionUniqueName_Success2";
            Schema       regionSchema            = null;
            Schema       nestedRegionSchema      = null;

            try
            {
                //init engine
                Component inputItem = (Component)TestSession.GetObject(CoreCoponentWebDavUrl);

                // Create TestData Regions
                Publication testPublication = (Publication)inputItem.ContextRepository;

                nestedRegionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = nestedRegionSchemaTitle,
                    Description = nestedRegionSchemaTitle
                };
                nestedRegionSchema.Save(true);

                regionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = regionShemaTitle,
                    Description = regionShemaTitle
                };
                SaveRegionSchemaWithRegionList(regionSchema, new object[] { regionShemaTitle, nestedRegionSchema, true });

                RenderedItem testRenderedItem;
                Package      testPackage    = RunTemplate(typeof(PublishMappings), inputItem, out testRenderedItem);
                Item         testItem       = testPackage.GetByName("/Preview/system/mappings/regions.json");
                var          content        = testItem.GetAsString();
                var          definedRegions = JsonConvert.DeserializeObject <List <RegionDefinitionTest> >(content);
                Assert.IsTrue(definedRegions.Count(x => x.Region == regionShemaTitle &&
                                                   x.ComponentTypes.Count == 1 &&
                                                   x.ComponentTypes[0].Schema == "*" &&
                                                   x.ComponentTypes[0].Template == "*"
                                                   ) == 1,
                              "TCM Region without any Component Presentations added to Regions.json");
            }
            finally
            {
                //Cleanup
                regionSchema?.Delete();
                nestedRegionSchema?.Delete();
            }
        }
        public void CreatePageModel_UrlPath_Success()
        {
            Page testPage1 = (Page)TestSession.GetObject(TestFixture.Tsi1278PageWebDavUrl);
            Page testPage2 = (Page)TestSession.GetObject(TestFixture.Tsi1278ChildPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel1 = CreatePageModel(testPage1, out testRenderedItem);
            PageModelData pageModel2 = CreatePageModel(testPage2, out testRenderedItem);

            // pageModel2 is in a Publication with empty PublicationURL (context-relative).
            // This leads to a context-relative UrlPath when testing, but it will be server-relative when publishing.
            Assert.AreEqual("/autotest-parent/tsi-1278_trådløst", pageModel1.UrlPath, "pageModel1.UrlPath");
            Assert.AreEqual("/tsi-1278_trådløst", pageModel2.UrlPath, "pageModel2.UrlPath");
        }
        public void CreatePageModel_KeywordModelExpansion_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi2316PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData  mainRegion          = GetMainRegion(pageModel);
            EntityModelData  testEntity          = mainRegion.Entities[0];
            KeywordModelData notPublishedKeyword = (KeywordModelData)testEntity.Content["notPublishedKeyword"];
            KeywordModelData publishedKeyword    = (KeywordModelData)testEntity.Content["publishedKeyword"];

            AssertExpanded(notPublishedKeyword, false, "notPublishedKeyword");
            AssertNotExpanded(publishedKeyword, true, "publishedKeyword");
        }
Пример #21
0
        public void Transform_GenerateSitemap_Success()
        {
            Component      navConfigComponent = (Component)TestSession.GetObject(TestFixture.NavConfigurationComponentWebDavUrl);
            Publication    testPublication    = (Publication)navConfigComponent.ContextRepository;
            StructureGroup rootStructureGroup = testPublication.RootStructureGroup;

            SitemapItemData sitemapRoot = RunTemplate <SitemapItemData>(typeof(GenerateSiteMap), navConfigComponent);

            Assert.AreEqual(rootStructureGroup.Id.ToString(), sitemapRoot.Id, "sitemapRoot.Id");
            Assert.AreEqual(rootStructureGroup.PublishLocationUrl, sitemapRoot.Url, "sitemapRoot.Url");
            Assert.AreEqual("StructureGroup", sitemapRoot.Type, "sitemapRoot.Type");
            Assert.AreEqual(rootStructureGroup.Title, sitemapRoot.Title, "sitemapRoot.Title");
            Assert.IsNotNull(sitemapRoot.Items, "sitemapRoot.Items");

            // TODO: further assertions
        }
        public void CreatePageModel_RichTextComponentLinks_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ArticlePageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData  mainRegion        = GetMainRegion(pageModel);
            EntityModelData  article           = mainRegion.Entities[0];
            ContentModelData articleBody       = (ContentModelData)article.Content["articleBody"];
            RichTextData     content           = (RichTextData)articleBody["content"];
            string           firstHtmlFragment = (string)content.Fragments[0];

            StringAssert.Contains(firstHtmlFragment, "href=\"tcm:1065-9710\"");
            StringAssert.Contains(firstHtmlFragment, "<!--CompLink tcm:1065-9710-->");
        }
        public void CreatePageModel_EmbeddedFields_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.Tsi1758PageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData mainRegion = GetMainRegion(pageModel);
            EntityModelData testEntity = mainRegion.Entities[0];

            ContentModelData[] topLevelEmbedField1 = (ContentModelData[])testEntity.Content["embedField1"];
            ContentModelData   nestedEmbedField1   = (ContentModelData)topLevelEmbedField1[0]["embedField1"];

            Assert.AreEqual("This is the textField of the first embedField1", topLevelEmbedField1[0]["textField"], "topLevelEmbedField1['textField']");
            Assert.AreEqual("This is the link text of embedField1 within the first embedField1", nestedEmbedField1["linkText"], "nestedEmbedField1['linkText']");
        }
Пример #24
0
        private Schema GetNewSchema(SchemaPurpose purpose)
        {
            //init engine
            Component inputItem = (Component)TestSession.GetObject(CoreComponentWebDavUrl);

            // Create TestData Regions
            Publication testPublication = (Publication)inputItem.ContextRepository;
            var         title           = Guid.NewGuid().ToString("N");
            var         schema          = new Schema(TestSession, testPublication.RootFolder.Id)
            {
                Purpose     = purpose,
                Title       = title,
                Description = title
            };

            return(schema);
        }
Пример #25
0
        private ComponentTemplate GetNewComponentTemaplate(Schema relatedSchema)
        {
            //init engine
            Component inputItem = (Component)TestSession.GetObject(CoreComponentWebDavUrl);

            // Create TestData Regions
            Publication testPublication   = (Publication)inputItem.ContextRepository;
            var         title             = Guid.NewGuid().ToString("N");
            var         componentTemplate = new ComponentTemplate(TestSession, testPublication.RootFolder.Id)
            {
                Title          = title,
                Description    = title,
                RelatedSchemas = { relatedSchema }
            };

            return(componentTemplate);
        }
        public void CreateEntityModel_WithoutComponentTemplate_Success()
        {
            string[]  articleDcpIds = TestFixture.ArticleDcpId.Split('/');
            Component testComponent = (Component)TestSession.GetObject(articleDcpIds[0]);

            RenderedItem    testRenderedItem;
            EntityModelData article = CreateEntityModel(testComponent, null, out testRenderedItem);

            AssertExpanded(article, true, "article");
            StringAssert.Matches(article.Id, new Regex(@"\d+"), "article.Id");
            Assert.IsNull(article.MvcData, "article.MvcData");
            Assert.IsNull(article.XpmMetadata, "article.XpmMetadata");

            Assert.IsNotNull(testRenderedItem, "testRenderedItem");
            Assert.AreEqual(2, testRenderedItem.Binaries.Count, "testRenderedItem.Binaries.Count");
            Assert.AreEqual(0, testRenderedItem.ChildRenderedItems.Count, "testRenderedItem.ChildRenderedItems.Count");
        }
        public void CreatePageModel_MetadataMerge_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.SmartTargetMetadataOverridePageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            ContentModelData pageModelMetadata = pageModel.Metadata;

            Assert.IsNotNull(pageModelMetadata, "pageModelMetadata");
            object allowDups;

            Assert.IsTrue(pageModelMetadata.TryGetValue("allowDuplicationOnSamePage", out allowDups), "pageModelMetadata['allowDuplicationOnSamePage']");
            Assert.AreEqual("True", allowDups, "allowDups"); // PT metadata overridden by Page metadata

            Assert.AreEqual("metadata merge test", pageModelMetadata["htmlClasses"], "pageModelMetadata['htmlClasses']");
        }
Пример #28
0
        public void Transform_AddNativeRegionNotUniqueName_Success()
        {
            const string regionShemaTitle        = "Main"; // Region with this name already exists in DXA Templates
            const string nestedRegionSchemaTitle = "AddNativeRegionNotUniqueName_Success";
            Schema       regionSchema            = null;
            Schema       nestedRegionSchema      = null;

            try
            {
                //init engine
                Component inputItem = (Component)TestSession.GetObject(CoreComponentWebDavUrl);

                // Create TestData Regions
                Publication testPublication = (Publication)inputItem.ContextRepository;

                nestedRegionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = nestedRegionSchemaTitle,
                    Description = nestedRegionSchemaTitle
                };
                nestedRegionSchema.Save(true);

                regionSchema = new Schema(TestSession, testPublication.RootFolder.Id)
                {
                    Purpose     = SchemaPurpose.Region,
                    Title       = regionShemaTitle,
                    Description = regionShemaTitle,
                };
                SaveRegionSchemaWithRegionList(regionSchema, new object[] { regionShemaTitle, nestedRegionSchema, true });

                var definedRegions = GetRenderedRegionDefinitions();
                Assert.IsTrue(definedRegions.Count(x => x.Region == regionShemaTitle &&
                                                   x.ComponentTypes.Any() &&
                                                   x.ComponentTypes[0].Schema != "*" &&
                                                   x.ComponentTypes[0].Template != "*"
                                                   ) == 1,
                              "DXA 'Main' Region and its ComponentTypes not overridden by TCM Region");
            }
            finally
            {
                //Cleanup
                Remove(regionSchema);
                Remove(nestedRegionSchema);
            }
        }
        public void DataPresentationTemplate_Success()
        {
            Page dummyPage = (Page)TestSession.GetObject(TestFixture.AutoTestParentHomePageWebDavUrl);

            RenderedItem renderedItem = CreateTestRenderedItem(dummyPage, dummyPage.PageTemplate);

            DataModelBuilderPipeline testModelBuilderPipeline = new DataModelBuilderPipeline(
                renderedItem,
                _defaultModelBuilderSettings,
                _defaultModelBuilderTypeNames,
                new ConsoleLogger()
                );

            ComponentTemplate dataPresentationTemplate = testModelBuilderPipeline.DataPresentationTemplate;

            Assert.IsNotNull(dataPresentationTemplate, "dataPresentationTemplate");
        }
        public void CreatePageModel_ContextExpressions_Success()
        {
            Page testPage = (Page)TestSession.GetObject(TestFixture.ContextExpressionsPageWebDavUrl);

            RenderedItem  testRenderedItem;
            PageModelData pageModel = CreatePageModel(testPage, out testRenderedItem);

            RegionModelData mainRegion = GetMainRegion(pageModel);

            EntityModelData[] entitiesWithExtensionData = mainRegion.Entities.Where(e => e.ExtensionData != null).ToArray();
            EntityModelData[] entitiesWithCxInclude     = entitiesWithExtensionData.Where(e => e.ExtensionData.ContainsKey("CX.Include")).ToArray();
            EntityModelData[] entitiesWithCxExclude     = entitiesWithExtensionData.Where(e => e.ExtensionData.ContainsKey("CX.Exclude")).ToArray();

            Assert.AreEqual(8, entitiesWithExtensionData.Length, "entitiesWithExtensionData.Length");
            Assert.AreEqual(6, entitiesWithCxInclude.Length, "entitiesWithCxInclude.Length");
            Assert.AreEqual(4, entitiesWithCxExclude.Length, "entitiesWithCxExclude.Length");
        }