예제 #1
0
        public void FindNode_ShouldReturnCorrectNodeRandom(int depth)
        {
            // arrange
            NodeTree <object> root = new NodeTree <object>(Guid.NewGuid(), new { testInt = 108, text = "test" });

            root.GenrateTree(depth, root, new { text = "test2" });
            NodeTree <object> randomNode = root.SelectRandomNode(root);

            // act
            var actual = root.FindNode(root, randomNode.GetNodeID());

            // assert
            Assert.AreEqual(randomNode, actual);
        }
예제 #2
0
        public void FindNode_ShouldReturnCorrectNodeSimple()
        {
            // arrange
            NodeTree <bool> root = new NodeTree <bool>(Guid.NewGuid(), true);

            root.SpawnChild(Guid.NewGuid(), true);
            root.SpawnChild(Guid.NewGuid(), false);
            Guid targetGuid = Guid.NewGuid();
            var  targetNode = root.SpawnChild(Guid.NewGuid(), true).SpawnChild(Guid.NewGuid(), false).SpawnChild(targetGuid, false);;

            // act
            var result = root.FindNode(root, targetGuid);

            // assert
            Assert.AreEqual(targetNode, result);
        }