コード例 #1
0
        static bool TestErrorFlow()
        {
            try
            {
                StateMachineWithoutValueImplementation sm = new StateMachineWithoutValueImplementation();

                sm.Execute(StateMachineWithoutValue.EventTypes.BeginTest);
                sm.Execute(StateMachineWithoutValue.EventTypes.Advance);
                try
                {
                    sm.Execute(StateMachineWithoutValue.EventTypes.CauseError);
                    Console.WriteLine("TestErrorFlow failed");
                    return(true);
                }
                catch (EnteredErrorStateException)
                {
                    //  This was supposed to happen
                }
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestErrorFlow raised " + e.Message);
                return(true);
            }
        }
コード例 #2
0
        static bool TestInvalidTransition()
        {
            try
            {
                StateMachineWithoutValueImplementation sm = new StateMachineWithoutValueImplementation();

                sm.Execute(StateMachineWithoutValue.EventTypes.BeginTest);
                sm.Execute(StateMachineWithoutValue.EventTypes.Advance);
                try
                {
                    sm.Execute(StateMachineWithoutValue.EventTypes.Advance);
                }
                catch (UnexpectedEventException)
                {
                    return(false);
                }
                Console.WriteLine("TestInvalidTransition failed");
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestInvalidTransition raised " + e.Message);
                return(true);
            }
        }
コード例 #3
0
        static bool TestEventAfterActionException()
        {
            try
            {
                StateMachineWithoutValueImplementation sm = new StateMachineWithoutValueImplementation();

                sm.Execute(StateMachineWithoutValue.EventTypes.BeginTest);
                sm.Execute(StateMachineWithoutValue.EventTypes.Advance);
                try
                {
                    sm.Execute(StateMachineWithoutValue.EventTypes.CauseActionError);
                    Console.WriteLine("TestErrorFlow failed");
                    return(true);
                }
                catch (ActionRaisedException)
                {
                    try
                    {
                        sm.Execute(StateMachineWithoutValue.EventTypes.Finish);
                        Console.WriteLine("TestEventAfterActionException failed");
                        return(true);
                    }
                    catch (EnteredErrorStateException)
                    {
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestEventAfterActionException raised " + e.Message);
                return(true);
            }
        }
コード例 #4
0
        static bool TestNormalFlow()
        {
            try
            {
                StateMachineWithoutValueImplementation sm = new StateMachineWithoutValueImplementation();

                sm.Execute(StateMachineWithoutValue.EventTypes.BeginTest);
                sm.Execute(StateMachineWithoutValue.EventTypes.Advance);
                sm.Execute(StateMachineWithoutValue.EventTypes.Finish);
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestNormalFlow raised " + e.Message);
                return(true);
            }
        }