Dotnet, Development, C Sharp Programming, Csharp, Microsoft.
accept an TimeProvider argument, which can be easily mocked, and you can then override the CreateTimer method and set a waiting time of TimeSpan.Zero for your tests. The ITimer created by CreateTimer is tied to the TimeProvider so the timers trigger as time advances. For example, consider the code