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 }
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 }
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); }
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 }