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

SystemClock

public static class SystemClock
Time related delegates used to support different compilation targets and to improve testability of the code.

Allows the setting of a custom method for cancelling tokens after a timespan, for use in testing. By default this will be a call to CancellationTokenSource.CancelAfter(timespan)

Allows the setting of a custom DateTimeOffset.UtcNow implementation for testing. By default this will be a call to UtcNow

Allows the setting of a custom Thread.Sleep implementation for testing. By default this will use the CancellationToken's WaitHandle.

Allows the setting of a custom async Sleep implementation for testing. By default this will be a call to Delay taking a CancellationToken

public static Func<DateTime> UtcNow

Allows the setting of a custom DateTime.UtcNow implementation for testing. By default this will be a call to UtcNow

public static void Reset()

Resets the custom implementations to their defaults. Should be called during test teardowns.