public void CurrentStateOnExit_IsCalled_ByTransition() { var state = new ExplicitState(); var initialState = Substitute.For <ExplicitState>(); var fsm = new FinitiStateMachine.FiniteStateMachine(initialState); fsm.Transition(state); initialState.Received().OnExit(); }
public void CurrentState_IsSetToInitialState_IfExplicitStateUpdateReturnsNull() { var state = new ExplicitState(); var newState = new ExplicitState(); var fsm = new FinitiStateMachine.FiniteStateMachine(state); fsm.Transition(newState); fsm.Update(); Assert.AreEqual(state, fsm.CurrentState); }
public void ExitState_IsCalled_ByTransition_IfStateIsDifferent() { var state = new ExplicitState(); var newState = new ExplicitState(); var fsm = new FinitiStateMachine.FiniteStateMachine(state); bool exitStateWasCalled = false; fsm.ExitState += () => exitStateWasCalled = true; fsm.Transition(newState); Assert.IsTrue(exitStateWasCalled); }