Ejemplo n.º 1
0
        public void When_interrupt_is_true_returns_assigned_interrupt_return_value()
        {
            var action = new BehaviourAction(() => BehaviourReturnCode.Success);

            var condition = new Conditional(() => true);

            var successInterruptable = new Interruptible(action, condition, BehaviourReturnCode.Success);
            var failureInterruptable = new Interruptible(action, condition, BehaviourReturnCode.Failure);
            var runningInterruptable = new Interruptible(action, condition, BehaviourReturnCode.Running);

            Assert.AreEqual(successInterruptable.Behave(), BehaviourReturnCode.Success);
            Assert.AreEqual(failureInterruptable.Behave(), BehaviourReturnCode.Failure);
            Assert.AreEqual(runningInterruptable.Behave(), BehaviourReturnCode.Running);
        }
Ejemplo n.º 2
0
        public void When_interrupt_is_false_child_behaves_as_normal()
        {
            var successAction = new BehaviourAction(() => BehaviourReturnCode.Success);
            var failureAction = new BehaviourAction(() => BehaviourReturnCode.Failure);
            var runningAction = new BehaviourAction(() => BehaviourReturnCode.Running);

            var condition = new Conditional(() => false);

            var successInterruptable = new Interruptible(successAction, condition, BehaviourReturnCode.Failure);
            var failureInterruptable = new Interruptible(failureAction, condition, BehaviourReturnCode.Failure);
            var runningInterruptable = new Interruptible(runningAction, condition, BehaviourReturnCode.Failure);

            Assert.AreEqual(successInterruptable.Behave(), BehaviourReturnCode.Success);
            Assert.AreEqual(failureInterruptable.Behave(), BehaviourReturnCode.Failure);
            Assert.AreEqual(runningInterruptable.Behave(), BehaviourReturnCode.Running);
        }