diff --git a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs index f1c580fe41d..42945860cfb 100644 --- a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs +++ b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs @@ -199,8 +199,6 @@ private void UpdateOriginalContext() return; } - Debug.Assert(Tasks.Count(t => t.IsAccepted) == 1, $"There must be exactly one accepted outcome for hedging. Found {Tasks.Count(t => t.IsAccepted)}."); - if (Tasks.FirstOrDefault(static t => t.IsAccepted) is TaskExecution acceptedExecution) { PrimaryContext!.Properties.AddOrReplaceProperties(acceptedExecution.Context.Properties); diff --git a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs index bb66c7f4d8b..26583198e2a 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs @@ -637,7 +637,7 @@ public async Task ExecuteAsync_EnsureBackgroundWorkInSuccessfulCallNotCancelled( await Assert.ThrowsAsync(() => backgroundTasks[0]); // background task is still pending - Assert.False(backgroundTasks[1].IsCompleted); + backgroundTasks[1].IsCompleted.Should().BeFalse(); cts.Cancel(); @@ -670,7 +670,7 @@ public async Task ExecuteAsync_ZeroHedgingDelay_EnsureAllTasksSpawnedAtOnce() var task = Create().ExecuteAsync(async c => (await Execute(c)).Result!, default); // assert - Assert.True(allExecutionsReached.WaitOne(AssertTimeout)); + allExecutionsReached.WaitOne(AssertTimeout).Should().BeTrue(); _timeProvider.Advance(LongDelay); await task; @@ -699,7 +699,7 @@ public void ExecuteAsync_InfiniteHedgingDelay_EnsureNoConcurrentExecutions() var pending = Create().ExecuteAsync(Execute, _cts.Token); // assert - Assert.True(allExecutions.WaitOne(AssertTimeout)); + allExecutions.WaitOne(AssertTimeout).Should().BeTrue(); async ValueTask Execute(CancellationToken token) {