//[Test, Explicit]
        public void TestDeferedTransitionsInSuperState()
        {
            TestHelpers.CatchUnexpected(() => {
                // Setting flip count will cause back and fourth between active and idle
                MyDataClass dataClass     = new MyDataClass();
                MySuperState notStartedSs = new NotStartedSs(null, dataClass);
                ISpEventListner listner;
                SpStateMachineEngine engine = this.GetEngine(out listner, dataClass, notStartedSs);
                listner.MsgReceived        += this.helpers.ListnerMsgDumpDelegate;
                listner.ResponseReceived   += this.helpers.ListnerResponseDumpDelegate;

                engine.Start();
                Thread.Sleep(600);

                Assert.AreEqual("NotStarted.Idle", notStartedSs.CurrentStateName);

                listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Start));
                Thread.Sleep(700);
                Assert.AreEqual("NotStarted.Active", notStartedSs.CurrentStateName);

                listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyMsgId.Abort));
                Thread.Sleep(700);
                Assert.AreEqual("NotStarted.Idle", notStartedSs.CurrentStateName);

                listner.MsgReceived      -= this.helpers.ListnerMsgDumpDelegate;
                listner.ResponseReceived -= this.helpers.ListnerResponseDumpDelegate;


                Thread.Sleep(200);
                engine.Stop();
                engine.Dispose();
                Console.WriteLine("Engine Disposed");
            });
        }
Ejemplo n.º 2
0
        public void TestDeferedTransitionsInSuperState()
        {
            TestHelpers.CatchUnexpected(() => {
                // Setting flip count will cause back and fourth between active and idle
                MyDataClass dataClass     = new MyDataClass();
                MySuperState notStartedSs = new NotStartedSs(null, dataClass);
                ISpStateMachine sm        = new MyStateMachine(dataClass, notStartedSs);

                //this.TickAndValidateState(new MyTickMsg(), sm, "NotStarted.Idle");
                //this.TickAndValidateState(new MyTickMsg(), sm, "NotStarted.Idle");

                this.TickAndValidateState(this.GetMsg(MyMsgId.Tick), sm, "NotStarted.Idle");
                this.TickAndValidateState(this.GetMsg(MyMsgId.Start), sm, "NotStarted.Active");
                this.TickAndValidateState(this.GetMsg(MyMsgId.Abort), sm, "NotStarted.Idle");
                this.TickAndValidateState(this.GetMsg(MyMsgId.Tick), sm, "NotStarted.Idle");
            });
        }
        //[Test, Explicit("experimental")]
        public void TestEventTransitionsInSuperState()
        {
            TestHelpers.CatchUnexpected(() => {
                // Setting flip count will cause back and fourth between active and idle
                MyDataClass dataClass = new MyDataClass()
                {
                    FlipStateCount = 2
                };
                MySuperState notStartedSs = new NotStartedSs(null, dataClass);
                ISpEventListner listner;
                SpStateMachineEngine engine = this.GetEngine(out listner, dataClass, notStartedSs);

                engine.Start();
                Thread.Sleep(2000);

                engine.Stop();
                engine.Dispose();
                Console.WriteLine("Engine Disposed");
            });
        }