Skip to content

Commit

Permalink
FIx hedging tests on .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Aug 10, 2023
1 parent f0b3417 commit 75ea78e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/Polly.Core.Tests/Hedging/HedgingTimeProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace Polly.Core.Tests.Hedging;

internal class HedgingTimeProvider : TimeProvider
Expand Down Expand Up @@ -26,7 +28,13 @@ public void Advance(TimeSpan diff)

public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var entry = new TimerEntry(dueTime, new TaskCompletionSource<bool>(), _utcNow.Add(dueTime), () => callback(state));
var timeStamp = dueTime switch
{
_ when dueTime == global::System.Threading.Timeout.InfiniteTimeSpan => DateTimeOffset.MaxValue,
_ => _utcNow.Add(dueTime)
};

var entry = new TimerEntry(dueTime, new TaskCompletionSource<bool>(), timeStamp, () => callback(state));
TimerEntries.Enqueue(entry);

Advance(AutoAdvance);
Expand Down

0 comments on commit 75ea78e

Please sign in to comment.