public void CreateNavigation_CallTheGetViewAction_EnsuresTheViewIsCreatedProperly()
        {
            // Arrange
            var viewName = "Toggle";
            using (var controller = new DummyNavigationController())
            {
                NavigationModel model = new NavigationModel();
                model.CssClass = "myClass";
                model.LevelsToInclude = 5;

                // Act
                var view = controller.GetView(viewName, model) as PartialViewResult;
                var resultNavigationModel = model as NavigationModel;

                // Assert
                Assert.AreEqual(viewName, view.ViewName, "The view name is not correct.");
                Assert.AreEqual(model, resultNavigationModel, "The model hasn't been passed to the view correctly.");
            }
        }
        public void NavigationWidget_SelectedPages()
        {
            string pageName1 = "NavigationPage1";
            string pageTitle1 = "Navigation Page1";
            string urlName1 = "navigation-page1";

            string pageName2 = "NavigationPage2";
            string pageTitle2 = "Navigation Page2";
            string urlName2 = "navigation-page2";

            string pageName3 = "NavigationPage3";
            string pageTitle3 = "Navigation Page3";
            string urlName3 = "navigation-page3";

            var fluent = App.WorkWith();
            var page1Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName1, pageTitle1, urlName1, null, false);
            this.createdPageIDs.Add(page1Key);

            var page2Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName2, pageTitle2, urlName2, null, false);
            this.createdPageIDs.Add(page2Key);

            var page3Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName3, pageTitle3, urlName3, null, false);
            this.createdPageIDs.Add(page3Key);

            var selectedPage1 = new SelectedPageModel();
            selectedPage1.Id = page1Key;
            var selectedPage2 = new SelectedPageModel();
            selectedPage2.Id = page2Key;

            var navModel = new NavigationModel(PageSelectionMode.SelectedPages, Guid.Empty, new[] { selectedPage1, selectedPage2 }, -1, false, string.Empty, false);

            var expectedCount = 2;
            var actualCount = navModel.Nodes.Count;
            Assert.AreEqual(expectedCount, actualCount);
            Assert.AreEqual(pageTitle1, navModel.Nodes[0].Title);
            Assert.AreEqual(pageTitle2, navModel.Nodes[1].Title);
        }
        public void NavigationWidget_AllChildPagesOfSpecifiedPage()
        {
            string pageName1 = "NavigationPage1";
            string pageTitle1 = "Navigation Page1";
            string urlName1 = "navigation-page1";

            string pageName2 = "NavigationPage2";
            string pageTitle2 = "Navigation Page2";
            string urlName2 = "navigation-page2";

            var fluent = App.WorkWith();
            var page1Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName1, pageTitle1, urlName1, null, false);

            this.createdPageIDs.Add(page1Key);

            var page1Node = fluent.Page(page1Key).Get();
            var page2Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName2, pageTitle2, urlName2, page1Node, false);

            this.createdPageIDs.Add(page2Key);

            var navModel = new NavigationModel(PageSelectionMode.SelectedPageChildren, page1Key, null, -1, false, string.Empty, false);

            var expectedCount = 1;
            var actualCount = navModel.Nodes.Count;
            Assert.AreEqual(expectedCount, actualCount);
            Assert.AreEqual(pageTitle2, navModel.Nodes[0].Title);
        }
        public void NavigationWidget_AllSiblingPagesOfCurrentlyOpenedPage()
        {
            string pageNamePrefix1 = "NavigationPage1";
            string pageTitlePrefix1 = "Navigation Page1";
            string urlNamePrefix1 = "navigation-page1";

            string pageNamePrefix2 = "NavigationPage2";
            string pageTitlePrefix2 = "Navigation Page2";
            string urlNamePrefix2 = "navigation-page2";

            var fluent = App.WorkWith();
            var page1Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageNamePrefix1, pageTitlePrefix1, urlNamePrefix1, null, false);

            this.createdPageIDs.Add(page1Key);

            var page2Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageNamePrefix2, pageTitlePrefix2, urlNamePrefix2, null, false);

            this.createdPageIDs.Add(page2Key);

            var page1Node = SitefinitySiteMap.GetCurrentProvider().FindSiteMapNodeFromKey(page1Key.ToString());
            SystemManager.CurrentHttpContext.Items[SiteMapBase.CurrentNodeKey] = page1Node;

            var navModel = new NavigationModel(PageSelectionMode.CurrentPageSiblings, Guid.Empty, null, -1, true, string.Empty, false);

            var expectedCount = 2;
            var actualCount = navModel.Nodes.Count;
            Assert.AreEqual(expectedCount, actualCount);
            Assert.AreEqual(pageTitlePrefix1, navModel.Nodes[0].Title);
        }