Ejemplo n.º 1
0
        public void FindNodesWhereComponentSingleRootExtension()
        {
            TestNode tree = CreateSimpleTestTree();

            IEnumerable <TestNode> findNodesResult = tree.FindNodesWhereComponent(comp => comp.Num == 3);

            Assert.Collection(findNodesResult, node => Assert.Equal("ChildNode", node.Name));

            IEnumerable <TestNode> findNodesResult2 = tree.FindNodesWhereComponent(comp => comp.Num == 6);

            Assert.Collection(findNodesResult2, node => Assert.Equal("RootNode", node.Name));
        }
Ejemplo n.º 2
0
        public void FindNodesWhereComponentByTypeSingleRootExtension()
        {
            TestNode tree = CreateSimpleTestTree();

            IEnumerable <TestNode> findNodesResult = tree.FindNodesWhereComponent <SpecialTestComponent>(comp => comp.SpecialId.Contains("special"));

            Assert.Collection(findNodesResult,
                              node => Assert.Equal("RootNode", node.Name),
                              node => Assert.Equal("ChildNode", node.Name)
                              );

            IEnumerable <TestNode> findNodesResult2 = tree.FindNodesWhereComponent <SomeOtherTestComponent>(comp => comp.SomeOtherValue == 3.1415f);

            Assert.Collection(findNodesResult2,
                              node => Assert.Equal("RootNode", node.Name)
                              );
        }
Ejemplo n.º 3
0
 // Find nodes containing matching components by type (and predicate)
 public static IEnumerable <TestNode> FindNodesWhereComponent <TComponentToFind>(this TestNode root, Predicate <TComponentToFind> match)
     where TComponentToFind : TestComponent
 => root.FindNodesWhereComponent <TComponentToFind, TestNode, TestComponent>(match);
Ejemplo n.º 4
0
 // Find nodes containing matching components by predicate only
 public static IEnumerable <TestNode> FindNodesWhereComponent(this TestNode root, Predicate <TestComponent> match)
 => root.FindNodesWhereComponent <TestNode, TestComponent>(match);