Esempio n. 1
0
        public void ShouldEndWithFailure_WhenYieldsFailure()
        {
            var timer      = new Clock();
            var blackboard = new Blackboard(timer);
            var action     = new CoroutineAction(TestFailCoroutine);
            var tree       = new TestRoot(blackboard, timer, action);

            tree.Start();                                              // First step should run
            timer.Update(0.1f);                                        // Tick - Second step should run
            timer.Update(0.1f);                                        // Tick - Third step should run

            Assert.AreEqual(Node.State.INACTIVE, action.CurrentState); // Action should have ended...
            Assert.IsFalse(action.DebugLastResult);                    // ... with failure
        }
Esempio n. 2
0
        public void StepAfterFailureShouldNotRun_WhenYieldsFailure()
        {
            var timer      = new Clock();
            var blackboard = new Blackboard(timer);
            var action     = new CoroutineAction(TestFailCoroutine);
            var tree       = new TestRoot(blackboard, timer, action);

            tree.Start();       // First step should run
            timer.Update(0.1f); // Tick - Second step should run
            timer.Update(0.1f); // Tick - Third step should run

            Assert.AreEqual(1, firstStepRunCount);
            Assert.AreEqual(1, secondStepRunCount);
            Assert.AreEqual(0, thirdStepRunCount); // Third step should not run as coroutine is failing earlier
        }
Esempio n. 3
0
        public void AllStepsShouldRun_WhenDoesntYieldFailure()
        {
            var timer      = new Clock();
            var blackboard = new Blackboard(timer);
            var action     = new CoroutineAction(TestCoroutine);
            var tree       = new TestRoot(blackboard, timer, action);

            tree.Start();       // First step should run
            timer.Update(0.1f); // Tick - Second step should run
            timer.Update(0.1f); // Tick - Third step should run

            Assert.AreEqual(1, firstStepRunCount);
            Assert.AreEqual(1, secondStepRunCount);
            Assert.AreEqual(1, thirdStepRunCount);
        }
Esempio n. 4
0
        public void ShouldEndWithSuccess_WhenDoesntYieldFailure()
        {
            var timer      = new Clock();
            var blackboard = new Blackboard(timer);
            var action     = new CoroutineAction(TestCoroutine);
            var tree       = new TestRoot(blackboard, timer, action);

            tree.Start();       // First step should run
            timer.Update(0.1f); // Tick - Second step should run
            timer.Update(0.1f); // Tick - Third step should run

            Assert.AreEqual(1, firstStepRunCount);
            Assert.AreEqual(1, secondStepRunCount);
            Assert.AreEqual(1, thirdStepRunCount);

            Assert.AreEqual(Node.State.INACTIVE, action.CurrentState); // Action should have ended...
            Assert.IsTrue(action.DebugLastResult);                     // ... with success
        }