Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }