コード例 #1
0
        /// <summary>
        /// Generate a Finite State Machine for use on method validation
        /// </summary>
        public Coc.Modeling.FiniteStateMachine.FiniteStateMachine GenerateTestMachine1()
        {
            //Initialize Test FSM
            Coc.Modeling.FiniteStateMachine.FiniteStateMachine fsm = new Coc.Modeling.FiniteStateMachine.FiniteStateMachine();

            State a = new State("A");
            State b = new State("B");
            State c = new State("C");
            State d = new State("D");
            State e = new State("E");
            State f = new State("F");

            fsm.AddState(a);
            fsm.AddState(b);
            fsm.AddState(c);
            fsm.AddState(d);
            fsm.AddState(e);
            fsm.AddState(f);

            fsm.AddTransition(new Transition(a, b, "a", "1"));
            fsm.AddTransition(new Transition(a, e, "x", "8"));
            fsm.AddTransition(new Transition(b, b, "y", "11"));
            fsm.AddTransition(new Transition(b, c, "b", "2"));
            fsm.AddTransition(new Transition(b, d, "c", "3"));
            fsm.AddTransition(new Transition(c, f, "s", "9"));
            fsm.AddTransition(new Transition(d, e, "z", "12"));
            fsm.AddTransition(new Transition(d, f, "d", "4"));
            fsm.AddTransition(new Transition(e, f, "f", "0"));

            fsm.InitialState = a;
            return(fsm);
        }
コード例 #2
0
        /// <summary>
        /// Generate a Finite State Machine for use on method validation
        /// </summary>
        public Coc.Modeling.FiniteStateMachine.FiniteStateMachine GenerateTestMachine2()
        {
            //Initialize Test FSM
            Coc.Modeling.FiniteStateMachine.FiniteStateMachine fsm = new Coc.Modeling.FiniteStateMachine.FiniteStateMachine();

            State _1 = new State("1");
            State _2 = new State("2");
            State _3 = new State("3");
            State _4 = new State("4");

            fsm.AddState(_1);
            fsm.AddState(_2);
            fsm.AddState(_3);
            fsm.AddState(_4);

            fsm.AddTransition(new Transition(_1, _2, "a", "1"));
            fsm.AddTransition(new Transition(_1, _3, "b", "0"));
            fsm.AddTransition(new Transition(_2, _3, "a", "1"));

            fsm.AddTransition(new Transition(_2, _4, "b", "0"));
            fsm.AddTransition(new Transition(_3, _4, "a", "0"));
            fsm.AddTransition(new Transition(_4, _1, "b", "0"));

            fsm.InitialState = _1;
            return(fsm);
        }