C#C
C#4y ago
bakk

Testing a class that relies on timers

I have a class RoutineManager that uses another class TimerScheduler to schedule different actions. This means that the timers decide the order of some function calls. I now need to test this. At first, I thought "oh I'll just mock the scheduler and make sure the functions get called", but quickly realised they won't be called in the correct order without the timers (which is the most important thing to test!). Does anyone have any suggestions of what I could do to test this? The only thing I can think of is changing the input to be in milliseconds instead of hours to make it quicker. However, I'm not sure timers are very reliable when you go down to single digit milliseconds or less (could be wrong), so it feels a bit hacky and potentially slow.
Was this page helpful?