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, Task> SleepAsync = Task.Delay;
public static Func<DateTime> UtcNow = () => DateTime.UtcNow;
public static void Reset()
{
Sleep = Thread.Sleep;
SleepAsync = Task.Delay;
UtcNow = (() => DateTime.UtcNow);
}
}
}