12345678910111213141516171819202122232425262728293031 |
- using System;
- using System.Collections.Generic;
- namespace Wayne.Lib.StateEngine.TestExtensions
- {
- /// <summary>
- /// Extension that can be used in unit tests to fire timers.
- /// </summary>
- public static class TimerTestExtension
- {
- /// <summary>
- /// Fires all actuve timers in the supplied state machine.
- /// </summary>
- /// <param name="stateMachine"></param>
- 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<TimerWrapper> tempTimerWrapperList = new List<TimerWrapper>(currentState.ParentStateMachine.timerWrapperList);
- foreach (var timerwrapper in tempTimerWrapperList)
- timerwrapper.Fire();
- currentState = currentState.ParentState;
- } while (currentState != null);
- }
- }
- }
|