<PackageReference Include="Polly" Version="4.3.0" />

SystemClock

public static class SystemClock
Time related delegates used to improve testability of the code
using System; using System.Threading; using System.Threading.Tasks; namespace Polly.Utilities { public static class SystemClock { public static Action<TimeSpan> Sleep = Thread.Sleep; public static Func<TimeSpan, CancellationToken, Task> SleepAsync = Task.Delay; public static Func<DateTime> UtcNow = () => DateTime.UtcNow; public static void Reset() { Sleep = Thread.Sleep; SleepAsync = Task.Delay; UtcNow = (() => DateTime.UtcNow); } } }