//! @brief FSMシステム初期化失敗テスト //! @return なし [Test] public void FSMSysmteInitializeFailedTest() { var log = string.Empty; var logMsgRecieved = new Application.LogCallback((condition, stackTrace, type) => { log = condition; }); Application.logMessageReceived += logMsgRecieved; var fsm = new FSMSystem(); fsm.initialize(new IFSMState[] { new FSMTestState(State.Test0, null), new FSMTestState(State.Test0, null), }); Application.logMessageReceived -= logMsgRecieved; var testLog = "State \"" + State.Test0 + "\" is duplicate !!!!!" + "\nFailed initialize FSMSystem ..." ; Assert.AreEqual(testLog, log); }
//! @brief FSMシステムテスト //! @return なし [Test] public void FSMSystemTest() { var log = new StringBuilder(); var fsm = new FSMSystem(); fsm.initialize(new IFSMState[] { new FSMTestState(State.Test0, log), new FSMTestStateToNext(State.Test1, log), new FSMTestState(State.Test2, log), }); fsm.execute(); log.AppendLine("setNextState(" + State.Test0 + ")"); fsm.setNextState(State.Test0); fsm.execute(); log.AppendLine("setNextState(" + State.Test1 + ")"); fsm.setNextState(State.Test1); fsm.execute(); fsm.execute(); var testResult = new StringBuilder() .AppendLine(State.Test0 + ".entry") .AppendLine(State.Test0 + ".exec") .AppendLine("setNextState(" + State.Test0 + ")") .AppendLine(State.Test0 + ".exec") .AppendLine("setNextState(" + State.Test1 + ")") .AppendLine(State.Test0 + ".exit") .AppendLine(State.Test1 + ".entry") .AppendLine(State.Test1 + ".exec") .AppendLine(State.Test1 + ".exit") .AppendLine(State.Test2 + ".entry") .AppendLine(State.Test2 + ".exec") ; Assert.AreEqual(testResult.ToString(), log.ToString()); }