Esempio n. 1
0
        public void Failure()
        {
            var myblackboard = new Blackboard();
            var node         = new RetryNode(new Task.AlwaysFailureNode(), 10);
            var result       = node.Execute(myblackboard);

            Assert.Equal(BehaviorReturnCode.Failure, result);
        }
Esempio n. 2
0
        public void Success()
        {
            var myblackboard = new Blackboard();
            var node         = new RetryNode(new Task.AlwaysSuccessNode(), 10);
            var result       = node.Execute(myblackboard);

            Assert.Equal(BehaviorReturnCode.Success, result);
        }
Esempio n. 3
0
        public void Execute()
        {
            var myblackboard = new Blackboard();

            var node = new RetryNode(new Task.ActionNode(blackboard =>
            {
                var attempt = (int)blackboard.Properties["Attempt"];
                if (attempt >= 5)
                {
                    return(BehaviorReturnCode.Success);
                }
                else
                {
                    return(BehaviorReturnCode.Failure);
                }
            }), 10, "Attempt");

            var result = node.Execute(myblackboard);

            Assert.Equal(BehaviorReturnCode.Success, result);
            Assert.Equal(5, (int)myblackboard.Properties["Attempt"]);
        }