public bool AddChildToParent(string parent, int index)
        {
            var success = new SuccessActionNode("Success");
            var bt      = new SimpleBehaviourTree();

            return(bt.AddChildToParent(success, parent, index));
        }
        public void RemoveChildFromParent(string node)
        {
            var bt         = new SimpleBehaviourTree();
            var parentNode = new NodeWithChildren("Node with children");
            var child1     = new SuccessActionNode("Success 1");
            var child2     = new FailActionNode("Fail 1");
            var child3     = new RunningActionNode("Running 1");

            bt.AddChildToParent(parentNode, "Root Node", 0);
            bt.AddChildToParent(child1, parentNode.Name, 0);
            bt.AddChildToParent(child2, parentNode.Name, 1);
            bt.AddChildToParent(child3, parentNode.Name, 2);

            var deletedNode = bt.RemoveChildFromParent(node, parentNode.Name);

            Assert.IsNotNull(deletedNode);
        }
        public void BFSTraversalHeightOne()
        {
            var bt = new SimpleBehaviourTree();

            var child1 = new SuccessActionNode("Success 1");
            var child2 = new FailActionNode("Fail 1");
            var child3 = new RunningActionNode("Running 1");

            var expected = new List <string>
            {
                bt.RootNode.Name,
                "Success 1",
                "Fail 1",
                "Running 1"
            };

            Assert.IsTrue(bt.AddChildToParent(child1, bt.RootNode.Name, 0) &&
                          bt.AddChildToParent(child2, bt.RootNode.Name, 1) &&
                          bt.AddChildToParent(child3, bt.RootNode.Name, 2));
            var traversalResult = bt.Traverse();
            var result          = traversalResult.Select(node => node.Name).ToList();

            Assert.IsTrue(expected.SequenceEqual(result));
        }