public void When_running_Then_re_evaluate_and_complete_with_many_behave_calls()
        {
            var sequence = new ExclusiveSequence(
                new BehaviourAction(CalledAndSuccess),
                new BehaviourAction(new TestHelper().RunningTwiceThenSuccess)
                );

            Assert.AreEqual(BehaviourReturnCode.Running, sequence.Behave());
            Assert.AreEqual(BehaviourReturnCode.Running, sequence.Behave());
            Assert.AreEqual(BehaviourReturnCode.Running, sequence.Behave());
            Assert.AreEqual(BehaviourReturnCode.Success, sequence.Behave());

            Assert.AreEqual(4, _calledAndSuccessTimes);
        }
 public void When_behave_running_takes_up_re_evaluating_prev_conditions()
 {
     var called = 0;
     var exclusive = new ExclusiveSequence(new Conditional(() =>
                             {
                                 called++;
                                 return true;
                             }),
                             TestHelper.CreateRunningAction(),
                             TestHelper.CreateRunningAction(),
                             TestHelper.CreateSuccessAction()
                             );
     exclusive.Behave();
     exclusive.Behave();
     Assert.AreEqual(2, called);
 }
        public void When_behave_Running_then_completes_until_running_behaviour()
        {
            _calledAndSuccessTimes = 0;
            var seq = new ExclusiveSequence(
                new BehaviourAction(CalledAndSuccess),
                new BehaviourAction(CalledAndRunning),
                new BehaviourAction(CalledAndSuccess));

            var returnCode = seq.Behave();

            Assert.AreEqual(1, _calledAndSuccessTimes);
            Assert.AreEqual(BehaviourReturnCode.Running, returnCode);
        }