コード例 #1
0
        public void Superstate_should_handle_event_when_guard_of_substate_does_not_pass()
        {
            using (var machine = new TestMachine <State, Event, EventArgs>())
            {
                machine.SetupSubstates(State.S1, HistoryType.None, State.S1_1, State.S1_2);
                machine.AddTransition(State.S1_1, Event.E1, State.S1_2);
                machine.AddTransition(State.S1_2, Event.E1, (sender, args) => false, State.S1_2);
                machine.AddTransition(State.S1, Event.E1, State.S2);

                IActiveStateMachine <State, Event, EventArgs> m = machine;
                registerMachineEvents(m);
                machine.Start(State.S1);
                m.SendSynchronously(Event.E1);
                Assert.AreEqual(State.S1_2, m.CurrentStateID);
                machine.SendSynchronously(Event.E1);
                Assert.AreEqual(State.S2, m.CurrentStateID);
                m.WaitForPendingEvents();
                assertMachineEvents(true, false, true, false);
            }
        }