Exemple #1
0
        public void GetPageModel_RetrofitMapping_Success() // See TSI-1757
        {
            ILocalization testLocalization = TestFixture.ChildLocalization;
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.Tsi1757PageRelativeUrlPath);

            PageModel pageModel = TestContentProvider.GetPageModel(testPageUrlPath, testLocalization, addIncludes: false);

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

            Tsi1757TestEntity3 testEntity3 = pageModel.Regions["Main"].Entities[0] as Tsi1757TestEntity3;

            Assert.IsNotNull(testEntity3, "testEntity3");

            Assert.AreEqual("This is the textField of TSI-1757 Test Component 3", testEntity3.TextField, "testEntity3.TextField");
            Assert.IsNotNull(testEntity3.CompLinkField, "testEntity3.CompLinkField");
            Assert.AreEqual(2, testEntity3.CompLinkField.Count, "testEntity3.CompLinkField.Count");

            Tsi1757TestEntity1 testEntity1 = testEntity3.CompLinkField[0] as Tsi1757TestEntity1;

            Assert.IsNotNull(testEntity1, "testEntity1");
            Assert.AreEqual("This is the textField of TSI-1757 Test Component 1", testEntity1.TextField, "testEntity1.TextField");
            Assert.AreEqual("This is the embeddedTextField of TSI-1757 Test Component 1", testEntity1.EmbeddedTextField, "testEntity1.EmbeddedTextField");

            Tsi1757TestEntity2 testEntity2 = testEntity3.CompLinkField[1] as Tsi1757TestEntity2;

            Assert.IsNotNull(testEntity2, "testEntity2");
            Assert.AreEqual("This is the textField of TSI-1757 Test Component 2", testEntity2.TextField, "testEntity2.TextField");
        }
        public void GetPageModel_NoXpmMetadataOnLive_Success() // See TSI-1942
        {
            ILocalization testLocalization = TestFixture.LegacyChildLocalization;
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.ArticlePageRelativeUrlPath);

            PageModel pageModel = TestContentProvider.GetPageModel(testPageUrlPath, testLocalization, addIncludes: true);

            Assert.IsNotNull(pageModel, "pageModel");
            Assert.IsNull(pageModel.XpmMetadata, "pageModel.XpmMetadata");
            Assert.AreEqual(string.Empty, pageModel.GetXpmMarkup(testLocalization), "pageModel.GetXpmMarkup(testLocalization)");

            RegionModel headerRegion = pageModel.Regions["Header"];

            Assert.IsNotNull(headerRegion, "headerRegion");
            Assert.IsNull(headerRegion.XpmMetadata, "headerRegion.XpmMetadata");

            RegionModel mainRegion = pageModel.Regions["Main"];

            Assert.IsNotNull(mainRegion, "mainRegion");
            Assert.IsNull(mainRegion.XpmMetadata, "mainRegion.XpmMetadata");

            Article testArticle = mainRegion.Entities[0] as Article;

            Assert.IsNotNull(testArticle, "Test Article not found on Page.");
            Assert.IsNull(testArticle.XpmMetadata, "testArticle.XpmMetadata");
            Assert.IsNull(testArticle.XpmPropertyMetadata, "testArticle.XpmPropertyMetadata");
            Assert.AreEqual(string.Empty, testArticle.GetXpmMarkup(testLocalization), "testArticle.GetXpmMarkup(testLocalization)");
        }
        public void GetContextNavigationLinks_TaxonomyTestPage2_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testUrlPath      = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyTestPage2RelativeUrlPath);

            NavigationLinks navLinks = _testNavigationProvider.GetContextNavigationLinks(testUrlPath, testLocalization);

            Assert.IsNotNull(navLinks, "navLinks");
            OutputJson(navLinks);

            AssertExpectedLinks(navLinks.Items);
        }
        public void GetBreadcrumbNavigationLinks_UnclassifiedPage_Success() // See TSI-1916
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.ArticlePageRelativeUrlPath);

            NavigationLinks navLinks = _testNavigationProvider.GetBreadcrumbNavigationLinks(testPageUrlPath, testLocalization);

            Assert.IsNotNull(navLinks, "navLinks");
            OutputJson(navLinks);

            Assert.IsNotNull(navLinks.Items, "navLinks.Items");
            Assert.AreEqual(0, navLinks.Items.Count, "navLinks.Items.Count");
        }
Exemple #5
0
        public void GetContextNavigationLinks_TaxonomyTestPage1_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testUrlPath      = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyTestPage1RelativeUrlPath);

            NavigationLinks navLinks = _testNavigationProvider.GetContextNavigationLinks(testUrlPath, testLocalization);

            Assert.IsNotNull(navLinks, "navLinks");
            OutputJson(navLinks);

            Assert.AreEqual(3, navLinks.Items.Count, "navLinks.Items.Count");
            AssertValidLink(navLinks.Items[0], testLocalization.Path + "/regression/taxonomy/index", "Navigation Taxonomy Index Page", null, "navLinks.Items[0]");
            AssertValidLink(navLinks.Items[1], testLocalization.Path + "/regression/taxonomy/nav-taxonomy-test-2", "Navigation Taxonomy Test Page 2", null, "navLinks.Items[1]");
            AssertValidLink(navLinks.Items[2], testLocalization.Path + "/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "navLinks.Items[2]");
        }
        public void ResolveLocalization_EscapedChars_Success() // See CRQ-1585
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.Tsi1278PageRelativeUrlPath);

            Uri testUrl = new Uri(TestBaseUrl + testPageUrlPath);

            ILocalization resolvedLocalization = _testLocalizationResolver.ResolveLocalization(testUrl);

            Assert.IsNotNull(resolvedLocalization, "resolvedLocalization");
            OutputJson(resolvedLocalization);

            Assert.AreEqual(testLocalization.Id, resolvedLocalization.Id, "resolvedLocalization.Id");
            Assert.AreEqual(testLocalization.Path, resolvedLocalization.Path, "resolvedLocalization.Path");
            Assert.AreNotEqual(DateTime.MinValue, resolvedLocalization.LastRefresh, "resolvedLocalization.LastRefresh");
        }
        public void GetBreadcrumbNavigationLinks_TaxonomyTestPage1_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testUrlPath      = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyTestPage1RelativeUrlPath);

            NavigationLinks navLinks = _testNavigationProvider.GetBreadcrumbNavigationLinks(testUrlPath, testLocalization);

            Assert.IsNotNull(navLinks, "navLinks");
            OutputJson(navLinks);

            Assert.AreEqual(4, navLinks.Items.Count, "navLinks.Items.Count");
            AssertValidLink(navLinks.Items[0], null, TestFixture.TopLevelKeyword1Title, "Top-level Keyword 1 (abstract)", "navLinks.Items[0]");
            AssertValidLink(navLinks.Items[1], null, "Keyword 1.1", "First child Keyword of Top-level Keyword 1", "navLinks.Items[1]");
            AssertValidLink(navLinks.Items[2], null, "Keyword 1.1.2", "Second child Keyword of Keyword 1.1", "navLinks.Items[2]");
            AssertValidLink(navLinks.Items[3], "/autotest-parent/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "navLinks.Items[3]");
        }
Exemple #8
0
        public void GetNavigationSubtree_IncludeAncestorsAndChildrenClassifiedPage_Success()
        {
            ILocalization testLocalization     = TestFixture.ParentLocalization;
            string        testPageUrlPath      = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyTestPage1RelativeUrlPath);
            TaxonomyNode  testTaxonomyRoot     = GetTestTaxonomy(null, -1);
            TaxonomyNode  testTopLevelKeyword1 = testTaxonomyRoot.Items.FirstOrDefault(i => i.Title == TestFixture.TopLevelKeyword1Title) as TaxonomyNode;

            Assert.IsNotNull(testTopLevelKeyword1, "testTopLevelKeyword1");
            TaxonomyNode testKeyword11 = testTopLevelKeyword1.Items.FirstOrDefault(i => i.Title == TestFixture.Keyword1_1Title) as TaxonomyNode;

            Assert.IsNotNull(testKeyword11, "testKeyword11");
            PageModel        testPageModel         = SiteConfiguration.ContentProvider.GetPageModel(testPageUrlPath, testLocalization);
            string           testPageSitemapItemId = string.Format("{0}-p{1}", testTaxonomyRoot.Id, testPageModel.Id);
            NavigationFilter testNavFilter         = new NavigationFilter {
                IncludeAncestors = true, DescendantLevels = 1
            };

            SitemapItem[] ancestorItems = _testOnDemandNavigationProvider.GetNavigationSubtree(testPageSitemapItemId, testNavFilter, testLocalization).ToArray();
            Assert.IsNotNull(ancestorItems, "ancestorItems");
            OutputJson(ancestorItems);

            // Result should be the Taxonomy Root only; it acts as the subtree root for all ancestors.
            Assert.AreEqual(1, ancestorItems.Length, "ancestorItems.Length");
            TaxonomyNode taxonomyRoot = ancestorItems[0] as TaxonomyNode;

            AssertExpectedTaxonomyNode(taxonomyRoot, testTaxonomyRoot.Title, 2, "taxonomyRoot");
            TaxonomyNode topLevelKeyword1 = taxonomyRoot.Items[0] as TaxonomyNode;

            AssertExpectedTaxonomyNode(topLevelKeyword1, testTopLevelKeyword1.Title, 2, "topLevelKeyword1");
            TaxonomyNode keyword11 = topLevelKeyword1.Items[0] as TaxonomyNode;

            AssertExpectedTaxonomyNode(keyword11, testKeyword11.Title, 2, "keyword11");
            TaxonomyNode keyword112 = keyword11.Items[1] as TaxonomyNode;

            AssertExpectedTaxonomyNode(keyword112, "Keyword 1.1.2", 1, "keyword112");
            TaxonomyNode keyword12 = topLevelKeyword1.Items[1] as TaxonomyNode;

            AssertExpectedTaxonomyNode(keyword12, "Keyword 1.2", 3, "keyword12");
            TaxonomyNode topLevelKeyword2 = taxonomyRoot.Items[1] as TaxonomyNode;

            AssertExpectedTaxonomyNode(topLevelKeyword2, TestFixture.TopLevelKeyword2Title, 3, "topLevelKeyword2");

            // Assert that child nodes are added because of DescendantLevels = 1:
            TaxonomyNode keyword111 = keyword11.Items[0] as TaxonomyNode;

            AssertExpectedTaxonomyNode(keyword111, "Keyword 1.1.1", 0, "keyword111");
        }
        public void GetContextNavigationLinks_TaxonomyIndexPage_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testUrlPathWithoutIndexSuffix = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyIndexPageRelativeUrlPath);
            string        testUrlPathWithIndexSuffix    = testUrlPathWithoutIndexSuffix + "/index";

            NavigationLinks navLinks  = _testNavigationProvider.GetContextNavigationLinks(testUrlPathWithoutIndexSuffix, testLocalization);
            NavigationLinks navLinks2 = _testNavigationProvider.GetContextNavigationLinks(testUrlPathWithIndexSuffix, testLocalization);

            Assert.IsNotNull(navLinks, "navLinks");
            Assert.IsNotNull(navLinks, "navLinks2");
            OutputJson(navLinks);
            OutputJson(navLinks2);

            AssertExpectedLinks(navLinks.Items);
            AssertExpectedLinks(navLinks2.Items);
        }
        private SitemapItem BuildNavigationModel(ILocalization localization)
        {
            using (new Tracer(localization))
            {
                string navigationJsonUrlPath = localization.GetAbsoluteUrlPath("navigation.json");

                Log.Debug("Deserializing Navigation Model from raw content URL '{0}'", navigationJsonUrlPath);
                IRawDataProvider rawDataProvider = SiteConfiguration.ContentProvider as IRawDataProvider;
                if (rawDataProvider == null)
                {
                    throw new DxaException(
                              $"The current Content Provider '{SiteConfiguration.ContentProvider.GetType().FullName}' does not implement interface '{typeof (IRawDataProvider).FullName}' and hence cannot be used in combination with Navigation Provider '{GetType().FullName}'."
                              );
                }

                return(JsonConvert.DeserializeObject <SitemapItem>(rawDataProvider.GetPageContent(navigationJsonUrlPath, localization)));
            }
        }
        public void GetNavigationSubtree_IncludeAncestorsUnclassifiedPage_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.ArticlePageRelativeUrlPath);

            TaxonomyNode     testTaxonomyRoot      = GetTestTaxonomy();
            PageModel        testPageModel         = SiteConfiguration.ContentProvider.GetPageModel(testPageUrlPath, testLocalization);
            string           testPageSitemapItemId = string.Format("{0}-p{1}", testTaxonomyRoot.Id, testPageModel.Id);
            NavigationFilter testNavFilter         = new NavigationFilter {
                IncludeAncestors = true, DescendantLevels = 0
            };

            SitemapItem[] ancestorItems = _testOnDemandNavigationProvider.GetNavigationSubtree(testPageSitemapItemId, testNavFilter, testLocalization).ToArray();
            Assert.IsNotNull(ancestorItems, "ancestorItems");
            OutputJson(ancestorItems);

            Assert.AreEqual(0, ancestorItems.Length, "ancestorItems.Length");
        }
        public void GetNavigationSubtree_PageDescendants_Success()
        {
            ILocalization testLocalization = TestFixture.ParentLocalization;
            TaxonomyNode  testTaxonomyRoot = GetTestTaxonomy();
            string        testPageUrlPath  = testLocalization.GetAbsoluteUrlPath(TestFixture.TaxonomyTestPage1RelativeUrlPath);


            PageModel        testPageModel         = SiteConfiguration.ContentProvider.GetPageModel(testPageUrlPath, testLocalization);
            string           testPageSitemapItemId = string.Format("{0}-p{1}", testTaxonomyRoot.Id, testPageModel.Id);
            NavigationFilter testNavFilter         = new NavigationFilter {
                DescendantLevels = 1
            };

            SitemapItem[] childItems = _testOnDemandNavigationProvider.GetNavigationSubtree(testPageSitemapItemId, testNavFilter, testLocalization).ToArray();
            Assert.IsNotNull(childItems, "childItems");
            OutputJson(childItems);

            Assert.AreEqual(0, childItems.Length, "childItems.Length");
        }