public void BreadcrumbModel_FromHomeToCurrentPage() { this.CreateTestPages(); var model = new BreadcrumbModel(); var viewModel = model.CreateViewModel(null); for (int i = 0; i < BreadcrumbWidgetTests.TestPagesCount; i++) { var expected = SitefinitySiteMap.GetCurrentProvider().FindSiteMapNodeFromKey(this.createdPageIDs[i].ToString()); var actual = viewModel.SiteMapNodes[i]; Assert.AreEqual(expected.Title, actual.Title); } }
public void BreadcrumbModel_FromHomeToCurrentPage_WithRestrictedPages() { this.CreateTestPages(); ObjectFactory.RegisterSitemapNodeFilter <DummySitemapFilter>("DummyFilter"); var restrictedPageIndex = 1; DummySitemapFilter.RestrictPageNode(this.createdPageIDs[restrictedPageIndex]); //// invalidates sitemap cache var inf = typeof(SiteMapBase).GetMethod("Reset", BindingFlags.Static | BindingFlags.NonPublic); inf.Invoke(null, null); using (var userReg = new CreateUserRegion("Viewer" + Guid.NewGuid().ToString("N") + "@mail.com", false)) { using (var profileReg = new CreateUserProfileRegion(userReg.User, "Viewer")) { using (new AuthenticateUserRegion(userReg.User)) { var model = new BreadcrumbModel(); var viewModel = model.CreateViewModel(null); var skipStep = 0; for (int i = 0; i < BreadcrumbWidgetTests.TestPagesCount; i++) { var expected = SitefinitySiteMap.GetCurrentProvider().FindSiteMapNodeFromKey(this.createdPageIDs[i].ToString()); if (i == restrictedPageIndex) { Assert.IsNull(expected); skipStep--; continue; } var breadcrumgIndex = i + skipStep; var actual = viewModel.SiteMapNodes[breadcrumgIndex]; Assert.AreEqual(expected.Title, actual.Title); } } } } DummySitemapFilter.Clear(); }
public void BreadcrumbModel_BreadcrumbExtender_VirtualNodes() { this.CreateTestPages(); var model = new BreadcrumbModel(); model.AllowVirtualNodes = true; var extender = new DummyBreadcrumbExtender(); var viewModel = model.CreateViewModel(extender); Assert.AreEqual(BreadcrumbWidgetTests.TestPagesCount + 1, viewModel.SiteMapNodes.Count); for (int i = 0; i < BreadcrumbWidgetTests.TestPagesCount; i++) { var expected = SitefinitySiteMap.GetCurrentProvider().FindSiteMapNodeFromKey(this.createdPageIDs[i].ToString()); var actual = viewModel.SiteMapNodes[i]; Assert.AreEqual(expected.Title, actual.Title); } Assert.AreEqual(DummyBreadcrumbExtender.DummySiteMapNodeTitle, viewModel.SiteMapNodes.Last().Title); }