public void Keep_Iterating_When_A_Posterior_Index_Is_Removed_On_Update()
        {
            var stateBehaviour1 = Substitute.For <IStateBehaviour>();
            var stateBehaviour2 = Substitute.For <IStateBehaviour>();
            var stateBehaviour3 = Substitute.For <IStateBehaviour>();

            var state = new BehaviouralState(stateBehaviour1, stateBehaviour2, stateBehaviour3);

            stateBehaviour2.When(behaviour => behaviour.OnUpdate())
            .Do(callbackInfo => state.RemoveBehaviour(stateBehaviour3));

            state.Update();

            stateBehaviour1.Received(1).OnUpdate();
            stateBehaviour2.Received(1).OnUpdate();
            stateBehaviour3.DidNotReceive().OnUpdate();
        }
        public void Keep_Iterating_When_A_Previous_Index_Is_Removed_On_Exit()
        {
            var stateBehaviour1 = Substitute.For <IStateBehaviour>();
            var stateBehaviour2 = Substitute.For <IStateBehaviour>();
            var stateBehaviour3 = Substitute.For <IStateBehaviour>();

            var state = new BehaviouralState(stateBehaviour1, stateBehaviour2, stateBehaviour3);

            stateBehaviour2.When(behaviour => behaviour.OnExit())
            .Do(callbackInfo => state.RemoveBehaviour(stateBehaviour1));

            state.Exit();

            stateBehaviour1.Received(1).OnExit();
            stateBehaviour2.Received(1).OnExit();
            stateBehaviour3.Received(1).OnExit();
        }
Exemplo n.º 3
0
 public bool RemoveBehaviour(IStateBehaviour stateBehaviour) => _innerBehaviouralState.RemoveBehaviour(stateBehaviour);