Beispiel #1
0
        public void Test_Finds_by_Predicate()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node1");
            var node5 = new Node ("Node1");
            var node6 = new Node ("Node6");
            node1.AddChild (node2);
            node1.AddChild (node3);
            node2.AddChild (node4);
            node3.AddChild (node5);

            var wld = new World ();
            wld.AddChild (node1);

            Assert.AreEqual (3, wld.Finds (x => x.Name == "Node1").Count());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node2").Count ());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node3").Count ());
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node4").Count ());

            // Update()を呼ぶまで更新されない
            wld.AddChild (node6);
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node6").Count ());

            wld.Update (0);
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node6").Count ());
        }