4 ms·
In the .NET world, the TimeProvider class, is in the .NET framework from version 8 onwards. (1) And a "wall clock" or "test clock" injected using DI as needed.
by SideburnsOfDoom 3y ago
In the .NET world, the TimeProvider class, is in the .NET framework from version 8 onwards. (1)
And a "wall clock" or "test clock" injected using DI as needed. (equivalent to option 1 + 4)
Write your own "test clock" or use the supplied fake: (2)
In earlier versions, we rolled our own "clock" interface.
1) https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.timeprov...
2) https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.time.testing.faketimeprovider https://learn.microsoft.com/en-us/dotnet/api/microsoft.exten...