Skip to content

Commit

Permalink
Remove unused MockTimeProvider methods
Browse files Browse the repository at this point in the history
Remove methods on `MockTimeProvider` that are unsed after the adoption of `FakeTimeProvider`.
  • Loading branch information
martincostello committed Jun 24, 2023
1 parent ad0c9a0 commit 518e354
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions test/Polly.Core.Tests/Helpers/MockTimeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,17 @@ namespace Polly.Core.Tests.Helpers;

internal class MockTimeProvider : Mock<TimeProvider>
{
private DateTimeOffset? _time;

public MockTimeProvider()
: base(MockBehavior.Strict)
{
}

public MockTimeProvider SetupUtcNow(DateTimeOffset? time = null)
{
_time = time ?? DateTimeOffset.UtcNow;
Setup(x => x.GetUtcNow()).Returns(() => _time.Value);
return this;
}

public MockTimeProvider AdvanceTime(TimeSpan time)
{
if (_time == null)
{
SetupUtcNow(DateTimeOffset.UtcNow);
}

_time = _time!.Value.Add(time);
return this;
}

public MockTimeProvider SetupTimestampFrequency()
{
Setup(x => x.TimestampFrequency).Returns(Stopwatch.Frequency);
return this;
}

public MockTimeProvider SetupAnyDelay(CancellationToken cancellationToken = default)
{
Setup(x => x.Delay(It.IsAny<TimeSpan>(), cancellationToken)).Returns(Task.CompletedTask);
return this;
}

public MockTimeProvider SetupGetTimestamp()
{
Setup(x => x.GetTimestamp()).Returns(0);
return this;
}

public MockTimeProvider SetupDelay(TimeSpan delay, CancellationToken cancellationToken = default)
{
Setup(x => x.Delay(delay, cancellationToken)).Returns(Task.CompletedTask);
Expand Down

0 comments on commit 518e354

Please sign in to comment.