예제 #1
0
        public void BuildsAllTheWayToTheRoot()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
예제 #2
0
 public void DoesntAddItemsInOffPaths()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     EnumerableAssert.Count(5, ih.EnumerateAllItems());
     EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_a);
     EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_b_a);
 }
예제 #3
0
        public void BuildsToRootWithRootAsLastItem()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a));

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
예제 #4
0
        public void BuildsToRootIfLastItemIsntA_Parent()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_b));

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
예제 #5
0
파일: Menu.cs 프로젝트: nikita239/Aspect
        private void BuildControlHierarchy(ContentItem currentItem, ContentItem startPage)
        {
            if (currentItem == null)
            {
                currentItem = startPage;
            }

            ItemList children = currentItem.GetChildren();

            if (children.Count > 0)
            {
                currentItem = children[0];
            }
            IEnumerable <ContentItem> ancestors = GetAncestors(currentItem, startPage);
            ContentItem startingPoint           = GetStartingPoint();

            if (startingPoint != null)
            {
                ItemHierarchyNavigator navigator;
                if (BranchMode)
                {
                    navigator = new ItemHierarchyNavigator(new BranchHierarchyBuilder(currentItem, startingPoint), Filters);
                }
                else
                {
                    navigator = new ItemHierarchyNavigator(new TreeHierarchyBuilder(startingPoint, MaxLevels), Filters);
                }
                if (navigator.Current != null)
                {
                    AddControlsRecursive(this, navigator, CurrentPage, ancestors);
                }
            }
        }
예제 #6
0
        public void CanBuild_Partial_HierarchyTree()
        {
            HierarchyNode <ContentItem> node = new TreeHierarchyBuilder(a_a).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.Count(3, ih.EnumerateAllItems());
        }
예제 #7
0
        public void StopsAtLastItemEvenIfNotRoot()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_a));

            Assert.AreEqual(a_a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
예제 #8
0
        public void CanBuild_HierarchyBranch_AndAddInitialsChildren_WithDifferent_InitialAsLast()
        {
            HierarchyNode <ContentItem> node = new BranchHierarchyBuilder(a_a, a, true).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.Count(5, ih.EnumerateAllItems());
        }
예제 #9
0
        public void AddsAllSiblings()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));

            EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_a);
            EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_b);
        }
예제 #10
0
        public void BuildHierarchyBranch_SameInitialAndLast()
        {
            HierarchyNode <ContentItem> node = new BranchHierarchyBuilder(a, a).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.Count(1, ih.EnumerateAllItems());
        }
예제 #11
0
        public void BuildHierarchyTree_CanTree_Depth3()
        {
            HierarchyNode <ContentItem> node = new TreeHierarchyBuilder(a, 3).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.Count(7, ih.EnumerateAllItems());
        }
예제 #12
0
 public void CanBuild_HierarchyBranch()
 {
     HierarchyNode<ContentItem> node = new BranchHierarchyBuilder(a_a_a, null).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
     EnumerableAssert.Count(5, ih.EnumerateAllItems());
 }
예제 #13
0
        public void DoesntAddItemsInOffPaths()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));

            EnumerableAssert.Count(5, ih.EnumerateAllItems());
            EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_a);
            EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_b_a);
        }
 public void BuildHierarchyTree_OtherNodes_AreNotIncluded()
 {
     HierarchyNode<ContentItem> node = new TreeHierarchyBuilder(a_b).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a);
     EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_a);
     EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_a_a);
 }
예제 #15
0
 private static void CompareItemsToRootRecursive(ContentItem root, ItemHierarchyNavigator ih)
 {
     foreach (ItemHierarchyNavigator childHierarchy in ih.Children)
     {
         Assert.AreEqual(root, childHierarchy.GetRootHierarchy().Current);
         CompareItemsToRootRecursive(root, childHierarchy);
     }
 }
예제 #16
0
        public void BuildHierarchyTree_OtherNodes_AreNotIncluded()
        {
            HierarchyNode <ContentItem> node = new TreeHierarchyBuilder(a_b).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a);
            EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_a);
            EnumerableAssert.DoesntContain(ih.EnumerateAllItems(), a_a_a);
        }
예제 #17
0
        public void CanBuild_HierarchyBranch()
        {
            HierarchyNode <ContentItem> node = new BranchHierarchyBuilder(a_a_a, null).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
            EnumerableAssert.Count(5, ih.EnumerateAllItems());
        }
예제 #18
0
파일: SiteTree.cs 프로젝트: dpawatts/zeus
 public TreeNodeBase ToTreeNode(bool rootOnly, bool withLinks)
 {
     IHierarchyNavigator<ContentItem> navigator = new ItemHierarchyNavigator(_treeBuilder, _filter);
     TreeNodeBase rootNode = BuildNodesRecursive(navigator, rootOnly, withLinks, _filter);
     //rootNode.ChildrenOnly = _excludeRoot;
     return rootNode;
 }
예제 #19
0
 public void BuildHierarchyBranch_SameInitialAndLast()
 {
     HierarchyNode<ContentItem> node = new BranchHierarchyBuilder(a, a).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(1, ih.EnumerateAllItems());
 }
예제 #20
0
 public void CanBuild_HierarchyBranch_AndAddInitialsChildren_WithDifferent_InitialAsLast()
 {
     HierarchyNode<ContentItem> node = new BranchHierarchyBuilder(a_a, a, true).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(5, ih.EnumerateAllItems());
 }
예제 #21
0
        public void CanBuildCompleteHierarchy()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new TreeHierarchyBuilder(a));

            EnumerableAssert.Count(7, ih.EnumerateAllItems());
        }
예제 #22
0
        public void CanFindRootLevelFromAllLevels()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));

            CompareItemsToRootRecursive(a, ih);
        }
예제 #23
0
 public void StopsAtLastItemEvenIfNotRoot()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_a));
     Assert.AreEqual(a_a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
예제 #24
0
 public void CanBuild_Partial_HierarchyTree()
 {
     HierarchyNode<ContentItem> node = new TreeHierarchyBuilder(a_a).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(3, ih.EnumerateAllItems());
 }
예제 #25
0
 public void CanFindRootLevelFromAllLevels()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     CompareItemsToRootRecursive(a, ih);
 }
예제 #26
0
 public void CanBuildCompleteHierarchy()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new TreeHierarchyBuilder(a));
     EnumerableAssert.Count(7, ih.EnumerateAllItems());
 }
예제 #27
0
 public void BuildsToRootWithRootAsLastItem()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
예제 #28
0
 public void BuildHierarchyTree_CanTree_Depth1()
 {
     HierarchyNode<ContentItem> node = new TreeHierarchyBuilder(a, 1).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(1, ih.EnumerateAllItems());
 }
예제 #29
0
 private static void CompareItemsToRootRecursive(ContentItem root, ItemHierarchyNavigator ih)
 {
     foreach (ItemHierarchyNavigator childHierarchy in ih.Children)
     {
         Assert.AreEqual(root, childHierarchy.GetRootHierarchy().Current);
         CompareItemsToRootRecursive(root, childHierarchy);
     }
 }
예제 #30
0
 public void BuildsAllTheWayToTheRoot()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
예제 #31
0
 public void AddsAllSiblings()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_a);
     EnumerableAssert.Contains(ih.EnumerateAllItems(), a_a_b);
 }
예제 #32
0
파일: Menu.cs 프로젝트: Jobu/n2cms
        private void BuildControlHierarchy(ContentItem currentItem, ContentItem startPage)
        {
            if(currentItem == null)
                currentItem = startPage;

            ItemList children = currentItem.GetChildren();
            if (children.Count > 0)
                currentItem = children[0];
            IEnumerable<ContentItem> ancestors = GetAncestors(currentItem, startPage);
            ContentItem startingPoint = GetStartingPoint();
            if(startingPoint != null)
            {
                ItemHierarchyNavigator navigator;
                if (BranchMode)
                {
                    navigator = new ItemHierarchyNavigator(new BranchHierarchyBuilder(currentItem, startingPoint), Filters);
                }
                else
                {
                    navigator = new ItemHierarchyNavigator(new TreeHierarchyBuilder(startingPoint, MaxLevels), Filters);
                }
                if (navigator.Current != null)
                {
                    AddControlsRecursive(this, navigator, CurrentPage, ancestors);
                }
            }
        }
예제 #33
0
 public void BuildsToRootIfLastItemIsntA_Parent()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_b));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }