Пример #1
0
        public void FirstAncestorOrSelf_OnTreeItem_OfTypeRoot_ReturnsNull()
        {
            var root     = EmptyRootNode.AddLeftContainers(EmptyContainerNode.AddItems(EmptyItemNode));
            var item     = root.LeftContainers[0].Items[0];
            var ancestor = item.FirstAncestorOrSelf <RootContainerNode>(_ => false);

            Assert.Null(ancestor);
        }
Пример #2
0
        public void Contains_Child_ReturnsFalse()
        {
            var root           = EmptyRootNode.AddLeftContainers(OneItemContainerPackage.CreateContainer());
            var otherContainer = root.LeftContainers[0].WithId("other");
            var contains       = root.Contains(otherContainer);

            Assert.False(contains);
        }
Пример #3
0
        public void Contains_Grandchild_ReturnsTrue()
        {
            var root     = EmptyRootNode.AddLeftContainers(OneItemContainerPackage.CreateContainer());
            var item     = root.LeftContainers[0].Items[0];
            var contains = root.Contains(item);

            Assert.True(contains);
        }
Пример #4
0
        public void Ancestors_OnGrandchild_ReturnsRoot()
        {
            var root      = EmptyRootNode.AddLeftContainers(OneItemContainerPackage.CreateContainer());
            var container = root.LeftContainers[0];
            var ancestors = container.Items[0].Ancestors();

            Assert.Collection(ancestors,
                              x => Assert.Same(container.Items, x),
                              x => Assert.Same(container, x),
                              x => Assert.Same(root.LeftContainers, x),
                              x => Assert.Same(root, x));
        }
Пример #5
0
            public static RootContainerNode Create()
            {
                var leaf      = EmptyItemNode;
                var container = EmptyContainerNode;

                return(EmptyRootNode
                       .AddLeftContainers(
                           container.AddItems(leaf, leaf),
                           container.AddItems(leaf))
                       .AddRightContainers(
                           container.AddItems(leaf),
                           container.AddItems(leaf, leaf)));
            }
Пример #6
0
        public void Children_OnRoot_ReturnsOnlyDirectChildren()
        {
            const string Container1Id = "container1";
            const string Container2Id = "container2";
            var          root         = EmptyRootNode
                                        .AddLeftContainers(OneItemContainerPackage.CreateContainer().WithId(Container1Id))
                                        .AddRightContainers(OneItemContainerPackage.CreateContainer().WithId(Container2Id));
            var children = root.Children();

            Assert.Collection(children,
                              x => Assert.IsType <ContainerListNode>(x),
                              x => Assert.IsType <ContainerListNode>(x));

            Assert.Collection((ContainerListNode)children.ElementAt(0),
                              x => Assert.True(x is ContainerNode c && c.Id == Container1Id));

            Assert.Collection((ContainerListNode)children.ElementAt(1),
                              x => Assert.True(x is ContainerNode c && c.Id == Container2Id));
        }