//[Test, Explicit] public void TestExitStateTransitionsInSuperState() { TestHelpers.CatchUnexpected(() => { // Setting flip count will cause back and fourth between active and idle MyDataClass dataClass = new MyDataClass(); MySuperState mainSs = new MainSs(dataClass); ISpEventListner listner; SpStateMachineEngine engine = this.GetEngine(out listner, dataClass, mainSs); engine.Start(); // Just move the inner states around Thread.Sleep(600); Assert.AreEqual("Main.NotStarted.Idle", mainSs.CurrentStateName); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Start)); Thread.Sleep(600); Assert.AreEqual("Main.NotStarted.Active", mainSs.CurrentStateName); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Stop)); Thread.Sleep(600); Assert.AreEqual("Main.NotStarted.Idle", mainSs.CurrentStateName); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Start)); Thread.Sleep(600); Assert.AreEqual("Main.NotStarted.Active", mainSs.CurrentStateName); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Stop)); Thread.Sleep(800); Assert.AreEqual("Main.NotStarted.Idle", mainSs.CurrentStateName); // Should be back to Main.NotStarted.Idle by now - it has a ExitState transition registered to that state Console.WriteLine("Sending the Abort event to provoke a ExitState transition"); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Abort)); Thread.Sleep(800); Assert.AreEqual("Main.Recovery.Idle", mainSs.CurrentStateName); engine.Stop(); engine.Dispose(); Console.WriteLine("Engine Disposed"); }); }
public void TestExitStateTransitionsInSuperState() { TestHelpers.CatchUnexpected(() => { // Setting flip count will cause back and fourth between active and idle MyDataClass dataClass = new MyDataClass(); MySuperState mainSs = new MainSs(dataClass); ISpStateMachine sm = new MyStateMachine(dataClass, mainSs); //this.TickAndValidateState(new MyTickMsg(), sm, "Main.NotStarted"); //this.TickAndValidateState(new MyTickMsg(), sm, "Main.NotStarted.Idle"); this.TickAndValidateState(this.GetMsg(MyMsgId.Tick), sm, "Main.NotStarted.Idle"); this.TickAndValidateState(this.GetMsg(MyMsgId.Start), sm, "Main.NotStarted.Active"); this.TickAndValidateState(this.GetMsg(MyMsgId.Stop), sm, "Main.NotStarted.Idle"); this.TickAndValidateState(this.GetMsg(MyMsgId.Abort), sm, "Main.Recovery.Idle"); //this.TickAndValidateState(this.GetMsg(MyEventType.Tick), sm, "Main.Recovery.Idle"); //Thread.Sleep(500); }); }