public void BuildsAllTheWayToTheRoot()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
 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 BuildsToRootWithRootAsLastItem()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a));

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

            Assert.AreEqual(a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
Exemple #5
0
        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);
                }
            }
        }
Exemple #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());
        }
        public void StopsAtLastItemEvenIfNotRoot()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_a));

            Assert.AreEqual(a_a, ih.Current);
            Assert.IsNull(ih.Parent);
        }
Exemple #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());
        }
        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);
        }
Exemple #10
0
        public void BuildHierarchyBranch_SameInitialAndLast()
        {
            HierarchyNode <ContentItem> node = new BranchHierarchyBuilder(a, a).Build();
            ItemHierarchyNavigator      ih   = new ItemHierarchyNavigator(node);

            EnumerableAssert.Count(1, ih.EnumerateAllItems());
        }
Exemple #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());
        }
 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());
 }
        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);
 }
 private static void CompareItemsToRootRecursive(ContentItem root, ItemHierarchyNavigator ih)
 {
     foreach (ItemHierarchyNavigator childHierarchy in ih.Children)
     {
         Assert.AreEqual(root, childHierarchy.GetRootHierarchy().Current);
         CompareItemsToRootRecursive(root, childHierarchy);
     }
 }
Exemple #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);
        }
Exemple #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());
        }
Exemple #18
0
 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;
 }
 public void BuildHierarchyBranch_SameInitialAndLast()
 {
     HierarchyNode<ContentItem> node = new BranchHierarchyBuilder(a, a).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(1, ih.EnumerateAllItems());
 }
 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());
 }
        public void CanBuildCompleteHierarchy()
        {
            ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new TreeHierarchyBuilder(a));

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

            CompareItemsToRootRecursive(a, ih);
        }
 public void StopsAtLastItemEvenIfNotRoot()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_a));
     Assert.AreEqual(a_a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
 public void CanBuild_Partial_HierarchyTree()
 {
     HierarchyNode<ContentItem> node = new TreeHierarchyBuilder(a_a).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(3, ih.EnumerateAllItems());
 }
 public void CanFindRootLevelFromAllLevels()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     CompareItemsToRootRecursive(a, ih);
 }
 public void CanBuildCompleteHierarchy()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new TreeHierarchyBuilder(a));
     EnumerableAssert.Count(7, ih.EnumerateAllItems());
 }
 public void BuildsToRootWithRootAsLastItem()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
 public void BuildHierarchyTree_CanTree_Depth1()
 {
     HierarchyNode<ContentItem> node = new TreeHierarchyBuilder(a, 1).Build();
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(node);
     EnumerableAssert.Count(1, ih.EnumerateAllItems());
 }
 private static void CompareItemsToRootRecursive(ContentItem root, ItemHierarchyNavigator ih)
 {
     foreach (ItemHierarchyNavigator childHierarchy in ih.Children)
     {
         Assert.AreEqual(root, childHierarchy.GetRootHierarchy().Current);
         CompareItemsToRootRecursive(root, childHierarchy);
     }
 }
 public void BuildsAllTheWayToTheRoot()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, null));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }
 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);
 }
Exemple #32
0
        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);
                }
            }
        }
 public void BuildsToRootIfLastItemIsntA_Parent()
 {
     ItemHierarchyNavigator ih = new ItemHierarchyNavigator(new BranchHierarchyBuilder(a_a_a, a_b));
     Assert.AreEqual(a, ih.Current);
     Assert.IsNull(ih.Parent);
 }