From 802820b98ef4bfeb5ac2d583af661d79394ec709 Mon Sep 17 00:00:00 2001 From: martintmk <103487740+martintmk@users.noreply.github.com> Date: Fri, 14 Jul 2023 09:09:21 +0200 Subject: [PATCH] Kill mutant (#1407) --- .../Controller/CircuitStateController.cs | 2 +- .../Controller/CircuitStateControllerTests.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs b/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs index 553cc7dc04b..1c595c3929f 100644 --- a/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs +++ b/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs @@ -221,7 +221,7 @@ public void Dispose() _disposed = true; } - private static async ValueTask ExecuteScheduledTaskAsync(Task? task, ResilienceContext context) + internal static async ValueTask ExecuteScheduledTaskAsync(Task? task, ResilienceContext context) { if (task is not null) { diff --git a/test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs b/test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs index 65460d9b9e6..d8090fcb574 100644 --- a/test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs +++ b/test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs @@ -403,6 +403,21 @@ public async Task Flow_Closed_HalfOpen_Open_HalfOpen_Closed() controller.CircuitState.Should().Be(CircuitState.Closed); } + [Fact] + public async Task ExecuteScheduledTask_Async_Ok() + { + var source = new TaskCompletionSource(); + var task = CircuitStateController.ExecuteScheduledTaskAsync(source.Task, ResilienceContext.Get().Initialize(isSynchronous: false)).AsTask(); + + task.Wait(3).Should().BeFalse(); + task.IsCompleted.Should().BeFalse(); + + source.SetResult("ok"); + + await task; + task.IsCompleted.Should().BeTrue(); + } + private static DateTimeOffset? GetBlockedTill(CircuitStateController controller) => (DateTimeOffset?)controller.GetType().GetField("_blockedUntil", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(controller)!;