public void HaltChildCallsChildHalt()
        {
            var children = new ReturnXNode[]
            {
                new ReturnXNode(NodeStatus.SUCCESS),
                new ReturnXNode(NodeStatus.FAILURE),
                new ReturnXNode(NodeStatus.RUNNING),
            };

            var node = new ReturnXControlNode(NodeStatus.SUCCESS, children);

            // halt each child in turn, assert no other halts were called
            for (int haltIndex = 0; haltIndex < children.Length; haltIndex++)
            {
                node.HaltChild(haltIndex);

                for (int i = 0; i < children.Length; i++)
                {
                    var child = children[i];
                    if (i <= haltIndex)
                    {
                        Assert.That(child.Halts, Is.EqualTo(1));
                    }
                    else
                    {
                        Assert.That(child.Halts, Is.EqualTo(0));
                    }
                }
            }
        }
        public void ReturnsX([Values] NodeStatus childStatus, [Values] NodeStatus expectedStatus)
        {
            // always ignores childStatus and simply returns expectedStatus
            var child = new ReturnXNode(childStatus);
            var node  = new ReturnXControlNode(expectedStatus, new INode[]
            {
                child,
            });

            var actualStatus = node.Tick();

            Assert.That(actualStatus, Is.EqualTo(expectedStatus));
        }
        public void HaltCallsAllChildrenHalt(int expectedHalts)
        {
            var children = new ReturnXNode[]
            {
                new ReturnXNode(NodeStatus.SUCCESS),
                new ReturnXNode(NodeStatus.FAILURE),
                new ReturnXNode(NodeStatus.RUNNING),
            };

            var node = new ReturnXControlNode(NodeStatus.SUCCESS, children);

            for (int i = 0; i < expectedHalts; i++)
            {
                node.Halt();
            }

            Assert.That(node.Halts, Is.EqualTo(expectedHalts));
            foreach (var child in children)
            {
                Assert.That(child.Halts, Is.EqualTo(expectedHalts));
            }
        }