© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
19 replies
bakk

Testing a class that relies on timers

I have a class
RoutineManager
RoutineManager
that uses another class
TimerScheduler
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Testing an abstract class
C#CC# / help
15mo ago
Call a property from a class that is within a class
C#CC# / help
3y ago
Parameterized Unit Testing Class Types
C#CC# / help
2y ago
❔ Timers are confusing
C#CC# / help
3y ago