public void TaskThatReturnsRunningAndIsThenSuperceded() { Counter <Blackboard> targetCounter; Counter <Blackboard> preCounter; FixedResultState <Blackboard> pre; FixedResultState <Blackboard> target; BehaviourTree <Blackboard> behaviourTree = new BehaviourTree <Blackboard>( "Base", new Selector <Blackboard>( preCounter = new Counter <Blackboard>( pre = new FixedResultState <Blackboard>(TaskState.Failure)), targetCounter = new Counter <Blackboard>( target = new FixedResultState <Blackboard>(TaskState.Running)))); behaviourTree.Tick().Should().Be(TaskState.Running); behaviourTree.Context.RunningTask.Should().Be(target); behaviourTree.Context.CurrentlyRunning.Should().Contain(targetCounter); behaviourTree.Context.CurrentlyRunning.Should().Contain(target); Verify(preCounter, TaskState.Failure, 1, 1, 1, true); Verify(targetCounter, TaskState.Running, 1, 1, 0, true); pre.ResultState = TaskState.Running; behaviourTree.Tick().Should().Be(TaskState.Running); behaviourTree.Context.RunningTask.Should().Be(pre); Verify(preCounter, TaskState.Running, 1, 1, 0, true); Verify(targetCounter, TaskState.Failure, 0, 0, 1, true); behaviourTree.Context.CurrentlyRunning.Should().Contain(preCounter); behaviourTree.Context.CurrentlyRunning.Should().Contain(pre); }
public void TaskThatReturnsFailureThenRunning() { Counter <Blackboard> x; FixedResultState <Blackboard> s; BehaviourTree <Blackboard> behaviourTree = new BehaviourTree <Blackboard>( "Base", x = new Counter <Blackboard>( s = new FixedResultState <Blackboard>(TaskState.Running))); behaviourTree.Tick().Should().Be(TaskState.Running); behaviourTree.Context.RunningTask.Should().Be(s); behaviourTree.Context.CurrentlyRunning.Should().Contain(x); Verify(x, TaskState.Running, 1, 1, 0, true); s.ResultState = TaskState.Failure; behaviourTree.Tick().Should().Be(TaskState.Failure); Verify(x, TaskState.Failure, 0, 1, 1, true); behaviourTree.Context.RunningTask.Should().BeNull(); behaviourTree.Context.CurrentlyRunning.Should().BeEmpty(); }