|
9 | 9 | def everFalse(): |
10 | 10 | return False |
11 | 11 |
|
| 12 | +def everTrue(): |
| 13 | + return True |
| 14 | + |
12 | 15 | def testPrint(): |
13 | 16 | print("Test") |
14 | 17 |
|
@@ -92,6 +95,34 @@ def test3(self): |
92 | 95 | sm.InjectEvent("ToNull") |
93 | 96 | self.assertEqual(sm.get_current_state(),"Exit", "Should be Exit") |
94 | 97 |
|
| 98 | + def test4(self): |
| 99 | + sm = StateMachine("../sample/sample4.xml") |
| 100 | + |
| 101 | + sm.LoadStateMachine() |
| 102 | + |
| 103 | + sm.addVariableToContext("testBaseStateMachine", "everFalse") |
| 104 | + sm.addVariableToContext("testBaseStateMachine", "everTrue") |
| 105 | + sm.addVariableToContext("testBaseStateMachine", "test") |
| 106 | + sm.addVariableToContext("testBaseStateMachine", "testPrint") |
| 107 | + |
| 108 | + self.assertEqual(sm.get_current_state(),"Enter", "Should be Enter") |
| 109 | + # Precondition Verified / Execute PreAction |
| 110 | + sm.InjectEvent("ToExit") |
| 111 | + self.assertEqual(sm.get_current_state(),"Exit", "Should be Exit") |
| 112 | + # Not Valid Event |
| 113 | + sm.InjectEvent("ToExit") |
| 114 | + self.assertEqual(sm.get_current_state(),"Exit", "Should be Exit") |
| 115 | + |
| 116 | + # Precondition Verified /Execute Post Action |
| 117 | + sm.InjectEvent("ToNull") |
| 118 | + self.assertEqual(sm.get_current_state(),"Null", "Should be Null") |
| 119 | + # Not Valid Event |
| 120 | + sm.InjectEvent("ToExit") |
| 121 | + self.assertEqual(sm.get_current_state(),"Null", "Should be Null") |
| 122 | + # Precondition Verified /Execute Post Action |
| 123 | + sm.InjectEvent("ToNull") |
| 124 | + self.assertEqual(sm.get_current_state(),"Null", "Should be Null") |
| 125 | + |
95 | 126 |
|
96 | 127 |
|
97 | 128 | if __name__ == '__main__': |
|
0 commit comments