コード例 #1
0
    bool TransitionOrderTest::runTest(NSFString& errorMessage)
    {
        startStateMachine();

        // Test 
        //  state machine start up 
        //  initial state entering 
        //  null transition.
        //  entry actions
        if (!testHarness.doesEventResultInState(NULL, &state1))
        {
            errorMessage = "State Machine did not start properly.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  that internal transitions are taken before external transitions
        //  internal tranision actions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state2))
        {
            errorMessage = "Internal transition was not taken before external transition.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  that local transitions are taken before external transitions
        //  that local tranisition properly exit sub states
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state3))
        {
            errorMessage = "Local transition was not taken before external transition.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  that internal transitions are taken before local transitions
        //  internal tranision actions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state4))
        {
            errorMessage = "Internal transition was not taken before local transition.";
            stopStateMachine(); 
            return false;
        }

        stopStateMachine();
        return true;
    }
コード例 #2
0
    bool StrategyTest::runTest(NSFString& errorMessage)
    {
        startStateMachine();

        // Test 
        //  state machine start up 
        //  initial state entering 
        //  null transition.
        //  entry actions
        if (!testHarness.doesEventResultInState(NULL, &state1))
        {
            errorMessage = "State Machine did not start properly.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state2))
        {
            errorMessage = "State Machine did not handle simple event triggered transition from state1 to state2.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        //  Test strategy event reception 
        if (!testHarness.doesEventResultInState(&state2Strategy.getEvent3(), &state3))
        {
            errorMessage = "State2Strategy did not handle event3 properly, stateMachine did not transition from state2 to state3.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        //  Test strategy re-entry
        if (!testHarness.doesEventResultInState(&event1, &state2Strategy.getState4()))
        {
            errorMessage = "State2Strategy did re-enter into the state state2Strategy.State4 correctly.";
            stopStateMachine(); 
            return false;
        }

        stopStateMachine();
        return true;
    }
コード例 #3
0
    bool ChoiceStateTest::runTest(NSFString& errorMessage)
    {
        startStateMachine();

        if (!testHarness.doesEventResultInState(NULL, &waitToEvaluateState))
        {
            errorMessage = "State Machine did not start properly";
            stopStateMachine(); 
            return false;
        }

        if (!testHarness.doesEventResultInState(&evaluateEvent, &valueLowState))
        {
            errorMessage = "Choice State did not choose low";
            stopStateMachine(); 
            return false;
        }

        if (!testHarness.doesEventResultInState(&waitEvent, &waitToEvaluateState))
        {
            errorMessage = "Simple Transition failed from valueLowState to waitToEvaluateState";
            stopStateMachine(); 
            return false;
        }

        if (!testHarness.doesEventResultInState(&evaluateEvent, &valueMiddleState))
        {
            errorMessage = "Choice State did not choose middle";
            stopStateMachine(); 
            return false;
        }

        if (!testHarness.doesEventResultInState(&waitEvent, &waitToEvaluateState))
        {
            errorMessage = "Simple Transition failed from valueMiddleState to waitToEvaluateState";
            stopStateMachine(); 
            return false;
        }

        if (!testHarness.doesEventResultInState(&evaluateEvent, &valueHighState))
        {
            errorMessage = "Choice State did not choose high";
            stopStateMachine(); 
            return false;
        }

        stopStateMachine();
        return true;
    }
コード例 #4
0
    bool StateMachineRestartTest::runTest(NSFString& errorMessage)
    {
        startStateMachine();

        // Test 
        //  state machine start up 
        //  initial state entering 
        //  null transition.
        //  entry actions
        if (!testHarness.doesEventResultInState(NULL, &state1))
        {
            errorMessage = "State Machine did not start properly.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state2))
        {
            errorMessage = "State Machine did not handle simple event triggered transition from state1 to state2";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event2, &state3))
        {
            errorMessage = "State Machine did not handle simple event triggered transition from state2 to state3";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state2))
        {
            errorMessage = "State Machine did not handle simple event triggered transition from state3 to state2";
            stopStateMachine(); 
            return false;
        }

        resetStateMachine();

        // Test 
        //  state machine restart
        //  initial state entering 
        //  null transition.
        //  entry actions
        if (!testHarness.doesEventResultInState(NULL, &state1))
        {
            errorMessage = "State Machine did not reset properly.";
            stopStateMachine(); 
            return false;
        }

        // Test 
        //  state machine event handling
        //  triggered transitions
        //  entry actions
        if (!testHarness.doesEventResultInState(&event1, &state2))
        {
            errorMessage = "State Machine did not handle simple event triggered transition from state1 to state2 after reset";
            stopStateMachine(); 
            return false;
        }

        stopStateMachine();
        return true;
    }