private void GeroMachineSampleForm_Load(object sender, EventArgs e)
        {
            AllTriggers = new Trigger[3]
            {
                new Trigger(),
                new Trigger(),
                new Trigger()
            };
            State[] all_states = new State[3]
            {
                new NormalState(AllTriggers),
                new NormalState(AllTriggers),
                new NormalState(AllTriggers)
            };
            all_states[0].StateName = "State 1";
            all_states[1].StateName = "State 2";
            all_states[2].StateName = "State 3";
            var matrixData = new Dictionary<State, Dictionary<Trigger, ITransition>>
            {
                {
                    all_states[0],
                    new Dictionary<Trigger, ITransition>
                    {
                        { AllTriggers[0], new Transition(all_states[1], null) },
                        { AllTriggers[1], new Transition(all_states[2], null) },
                    }
                },
                {
                    all_states[1],
                    new Dictionary<Trigger, ITransition>
                    {
                        { AllTriggers[0], new Transition(all_states[2], null) },
                        { AllTriggers[1], new Transition(all_states[2], null) },
                        { AllTriggers[2], new Transition(all_states[0], null) }
                    }
                },
                {
                    all_states[2],
                    new Dictionary<Trigger, ITransition>
                    {
                        { AllTriggers[0], new Transition(all_states[2], null) },
                        { AllTriggers[2], new Transition(all_states[0], null) }
                    }
                }
            };

            TransitionMatrix transitino_matrix = new TransitionMatrix(matrixData);

            MainStateMachine = new StateMachine(all_states[0], transitino_matrix);
            CurrentStateNameLabel.Text = MainStateMachine.CurrentStateName;
        }
 public RegularInstanceTest()
 {
     All_Triggers = new Trigger[5]
     {
         new Trigger(),
         new Trigger(),
         new Trigger(),
         new Trigger(),
         new Trigger()
     };
     Trigger[] TriggerSet1 = new Trigger[3]
     {
         All_Triggers[0],
         All_Triggers[1],
         All_Triggers[2]
     };
     Trigger[] TriggerSet2 = new Trigger[3]
     {
         All_Triggers[0],
         All_Triggers[2],
         All_Triggers[4]
     };
     Trigger[] TriggerSet3 = new Trigger[3]
     {
         All_Triggers[2],
         All_Triggers[3],
         All_Triggers[4]
     };
     All_States = new State[3]
     {
         new NormalState(TriggerSet1),
         new NormalState(TriggerSet2),
         new NormalState(TriggerSet3)
     };
     setting_MatrixData = new Dictionary<State, Dictionary<Trigger, ITransition>>()
     {
         {
             All_States[0],
             new Dictionary<Trigger, ITransition>()
             {
                 { TriggerSet1[0], new Transition(All_States[2], null) },
                 { TriggerSet1[1], new Transition(All_States[2], null) },
                 { TriggerSet1[2], new Transition(All_States[1], null) }
             }
         },
         {
             All_States[1],
             new Dictionary<Trigger, ITransition>()
             {
                 { TriggerSet2[0], new Transition(All_States[0], null) },
                 { TriggerSet2[1], new Transition(All_States[1], null) },
                 { TriggerSet2[2], new Transition(All_States[2], null) }
             }
         },
         {
             All_States[2],
             new Dictionary<Trigger, ITransition>()
             {
                 { TriggerSet3[0], new Transition(All_States[2], null) },
                 { TriggerSet3[1], new Transition(All_States[2], null) },
                 { TriggerSet3[2], new Transition(All_States[0], null) }
             }
         }
     };
     TransitionMatrixInstance = new TransitionMatrix(setting_MatrixData);
 }
            public void TestConstructor()
            {
                // Prepare datas
                Trigger[] all_triggers = new Trigger[5]
                {
                    new Trigger(),
                    new Trigger(),
                    new Trigger(),
                    new Trigger(),
                    new Trigger()
                };
                TriggerSet1 = new Trigger[3]
                {
                    all_triggers[0],
                    all_triggers[1],
                    all_triggers[2]
                };
                TriggerSet2 = new Trigger[3]
                {
                    all_triggers[0],
                    all_triggers[2],
                    all_triggers[4]
                };
                TriggerSet3 = new Trigger[3]
                {
                    all_triggers[2],
                    all_triggers[3],
                    all_triggers[4]
                };
                State[] states = new State[3]
                {
                    new NormalState(TriggerSet1),
                    new NormalState(TriggerSet2),
                    new NormalState(TriggerSet3)
                };
                var input_transitionMatrix = new Dictionary<State, Dictionary<Trigger, ITransition>>()
                {
                    {
                        states[0],
                        new Dictionary<Trigger, ITransition>()
                        {
                            { TriggerSet1[0], new Transition(states[2], null) },
                            { TriggerSet1[1], new Transition(states[2], null) },
                            { TriggerSet1[2], new Transition(states[1], null) }
                        }
                    },
                    {
                        states[1],
                        new Dictionary<Trigger, ITransition>()
                        {
                            { TriggerSet2[0], new Transition(states[0], null) },
                            { TriggerSet2[1], new Transition(states[1], null) },
                            { TriggerSet2[2], new Transition(states[2], null) }
                        }
                    },
                    {
                        states[2],
                        new Dictionary<Trigger, ITransition>()
                        {
                            { TriggerSet3[0], new Transition(states[2], null) },
                            { TriggerSet3[1], new Transition(states[2], null) },
                            { TriggerSet3[2], new Transition(states[0], null) }
                        }
                    }
                };
                var expected_MatrixData = new Dictionary<State, Dictionary<Trigger, ITransition>>(input_transitionMatrix);

                // Execute
                TransitionMatrix transition_matrix = new TransitionMatrix(input_transitionMatrix);

                // Get result
                FieldInfo field_info = transition_matrix.GetType().GetField("MatrixData",
                    BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                var actual_MatrixData = (Dictionary<State, Dictionary<Trigger, ITransition>>)field_info.GetValue(transition_matrix);

                // Validate
                Assert.Same(input_transitionMatrix, actual_MatrixData);
                Assert.Equal(expected_MatrixData, actual_MatrixData);
            }
 public void TestNullArgumentConstructor()
 {
     // Execute
     TransitionMatrix transition_matrix;
     Assert.Throws<ArgumentNullException>(
         "transitionMatrix",
         () => transition_matrix = new TransitionMatrix(null)
     );
 }