public void PriorityEventsQueueing(
            IStateMachine <string, int> machine,
            AutoResetEvent signal)
        {
            const int FirstEvent  = 0;
            const int SecondEvent = 1;

            "establish an active state machine with transitions"._(() =>
            {
                signal = new AutoResetEvent(false);

                machine = new ActiveStateMachine <string, int>();

                machine.In("A").On(SecondEvent).Goto("B");
                machine.In("B").On(FirstEvent).Goto("C");
                machine.In("C").ExecuteOnEntry(() => signal.Set());

                machine.Initialize("A");
            });

            "when firing a priority event onto the state machine"._(() =>
            {
                machine.Fire(FirstEvent);
                machine.FirePriority(SecondEvent);
                machine.Start();
            });

            "it should queue event at the front"._(() =>
                                                   signal.WaitOne(1000).Should().BeTrue("state machine should arrive at destination state"));
        }
        public void CustomFactory(
            ActiveStateMachine <string, int> machine,
            StandardFactory <string, int> factory)
        {
            "establish a custom factory"._(() =>
            {
                factory = A.Fake <StandardFactory <string, int> >();
            });

            "when creating an active state machine"._(() =>
            {
                machine = new ActiveStateMachine <string, int>("_", factory);

                machine.In("initial").On(42).Goto("answer");
            });

            "it should use custom factory to create internal instances"._(() =>
                                                                          A.CallTo(factory).MustHaveHappened());
        }
        public void DefaultStateMachineName(
            ActiveStateMachine <string, int> machine,
            StateMachineNameReporter reporter)
        {
            "establish an instantiated active state machine"._(() =>
            {
                machine = new ActiveStateMachine <string, int>();
            });

            "establish a state machine reporter"._(() =>
            {
                reporter = new StateMachineNameReporter();
            });

            "when the state machine report is generated"._(() =>
                                                           machine.Report(reporter));

            "it should use the type of the state machine as name for state machine"._(() =>
                                                                                      reporter.StateMachineName
                                                                                      .Should().Be("Appccelerate.StateMachine.ActiveStateMachine<System.String,System.Int32>"));
        }
        public void CustomStateMachineName(
            ActiveStateMachine <string, int> machine,
            StateMachineNameReporter reporter)
        {
            const string Name = "custom name";

            "establish an instantiated active state machine with custom name"._(() =>
            {
                machine = new ActiveStateMachine <string, int>(Name);
            });

            "establish a state machine reporter"._(() =>
            {
                reporter = new StateMachineNameReporter();
            });

            "when the state machine report is generated"._(() =>
                                                           machine.Report(reporter));

            "it should use custom name for state machine"._(() =>
                                                            reporter.StateMachineName
                                                            .Should().Be(Name));
        }