using System; using System.Collections.Generic; namespace Wayne.Lib.StateEngine.TestExtensions { /// /// Extension that can be used in unit tests to fire timers. /// public static class TimerTestExtension { /// /// Fires all actuve timers in the supplied state machine. /// /// public static void FireTimers(StateMachine stateMachine) { State currentState = stateMachine.CurrentStateRecursive; do { Console.WriteLine("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); Console.WriteLine("FireTimers: Fireing {0} timers in {1}", currentState.ParentStateMachine.timerWrapperList.Count, currentState.ParentStateMachine.Name); Console.WriteLine("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); List tempTimerWrapperList = new List(currentState.ParentStateMachine.timerWrapperList); foreach (var timerwrapper in tempTimerWrapperList) timerwrapper.Fire(); currentState = currentState.ParentState; } while (currentState != null); } } }