namespace ZB.MOM.WW.Secrets.Tests.Fakes; /// /// A test double with a settable , so a test can /// advance the clock past a cache TTL deterministically without sleeping. /// public sealed class MutableTimeProvider : TimeProvider { private DateTimeOffset _utcNow; /// Creates a provider starting at the given instant (defaults to the Unix epoch). /// The initial value. public MutableTimeProvider(DateTimeOffset? start = null) => _utcNow = start ?? DateTimeOffset.UnixEpoch; /// Gets or sets the current UTC instant this provider reports. public DateTimeOffset UtcNow { get => _utcNow; set => _utcNow = value; } /// Moves the clock forward by . /// The amount to advance. public void Advance(TimeSpan delta) => _utcNow += delta; /// public override DateTimeOffset GetUtcNow() => _utcNow; }