diff --git a/build.cake b/build.cake index 851bf50dc5a..781a478b4fd 100644 --- a/build.cake +++ b/build.cake @@ -10,7 +10,7 @@ var configuration = Argument("configuration", "Release"); ////////////////////////////////////////////////////////////////////// #Tool "xunit.runner.console&version=2.4.2" -#Tool "dotnet-stryker&version=3.7.0" +#Tool "dotnet-stryker&version=3.7.1" ////////////////////////////////////////////////////////////////////// // EXTERNAL NUGET LIBRARIES diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.Task.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.Task.cs index 43b6c89095f..227374628ed 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.Task.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.Task.cs @@ -15,14 +15,12 @@ private static IEnumerable ExecuteAsTaskAsync_EnsureCorrectBe { Caption = "ExecuteAsTaskAsync_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteTaskAsync(async t => { t.Should().Be(CancellationToken); }, CancellationToken)) { Caption = "ExecuteAsTaskAsync_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); }, ResilienceContext.Get(), "dummy-state")) @@ -45,8 +43,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.TaskT.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.TaskT.cs index 792911e964d..14ee4efeb4f 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.TaskT.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.TaskT.cs @@ -17,14 +17,12 @@ private static IEnumerable ExecuteAsTaskAsyncT_EnsureCorrectB { Caption = "ExecuteAsTaskAsyncT_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteTaskAsync(async t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result) { Caption = "ExecuteAsTaskAsyncT_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result) @@ -48,8 +46,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs index 5b429f3bc1e..66584d9e142 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs @@ -15,14 +15,12 @@ private static IEnumerable ExecuteAsync_EnsureCorrectBehavior { Caption = "ExecuteAsync_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteValueTaskAsync(async t => { t.Should().Be(CancellationToken); }, CancellationToken)) { Caption = "ExecuteAsync_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteValueTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); }, ResilienceContext.Get(), "dummy-state")) @@ -45,8 +43,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs index 4870e51844d..caa8d1e3129 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs @@ -17,14 +17,12 @@ private static IEnumerable ExecuteAsyncT_EnsureCorrectBehavio { Caption = "ExecuteAsyncT_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteValueTaskAsync(async t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result) { Caption = "ExecuteAsyncT_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.ExecuteValueTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result) @@ -48,8 +46,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.Sync.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.Sync.cs index a2f50dc1238..ed79a097c42 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.Sync.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.Sync.cs @@ -13,14 +13,12 @@ private static IEnumerable Execute_EnsureCorrectBehavior_Exec { Caption = "Execute_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.Execute(t => { t.Should().Be(CancellationToken); }, CancellationToken)) { Caption = "Execute_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.Execute((_, s) => { s.Should().Be("dummy-state"); }, ResilienceContext.Get(), "dummy-state")) @@ -43,8 +41,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/ResilienceStrategyTests.SyncT.cs b/src/Polly.Core.Tests/ResilienceStrategyTests.SyncT.cs index 1cf24a7dd9c..78099574daa 100644 --- a/src/Polly.Core.Tests/ResilienceStrategyTests.SyncT.cs +++ b/src/Polly.Core.Tests/ResilienceStrategyTests.SyncT.cs @@ -15,14 +15,12 @@ private static IEnumerable ExecuteT_EnsureCorrectBehavior_Exe { Caption = "ExecuteT_NoCancellation", AssertContext = AssertResilienceContext, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.Execute(t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result) { Caption = "ExecuteT_Cancellation", AssertContext = AssertResilienceContextAndToken, - AssertContextAfter = AssertContextNotInitialized, }; yield return new ExecuteParameters(r => r.Execute((_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result) @@ -46,8 +44,6 @@ static void AssertResilienceContextAndToken(ResilienceContext context) context.CancellationToken.Should().Be(CancellationToken); } - static void AssertContextNotInitialized(ResilienceContext context) => context.IsInitialized.Should().BeFalse(); - static void AssertContextInitialized(ResilienceContext context) => context.IsInitialized.Should().BeTrue(); } diff --git a/src/Polly.Core.Tests/Utils/TimeProviderExtensionsTests.cs b/src/Polly.Core.Tests/Utils/TimeProviderExtensionsTests.cs index 0335a4de968..313d6640bfb 100644 --- a/src/Polly.Core.Tests/Utils/TimeProviderExtensionsTests.cs +++ b/src/Polly.Core.Tests/Utils/TimeProviderExtensionsTests.cs @@ -54,6 +54,24 @@ await TestUtils.AssertWithTimeoutAsync(async () => }); } + [Fact] + public async Task DelayAsync_SystemSynchronousWhenCancelled_Ok() + { + using var cts = new CancellationTokenSource(5); + var delay = TimeSpan.FromMilliseconds(10); + var context = ResilienceContext.Get(); + context.Initialize(isSynchronous: true); + context.CancellationToken = cts.Token; + + await TestUtils.AssertWithTimeoutAsync(async () => + { + await TimeProvider.System + .Invoking(p => p.DelayAsync(delay, context)) + .Should() + .ThrowAsync(); + }); + } + [InlineData(false, false)] [InlineData(false, true)] [InlineData(true, false)] diff --git a/src/Polly.RateLimiting.Tests/RateLimiterResilienceStrategyBuilderExtensionsTests.cs b/src/Polly.RateLimiting.Tests/RateLimiterResilienceStrategyBuilderExtensionsTests.cs index 7a5598c1039..85a1354ae63 100644 --- a/src/Polly.RateLimiting.Tests/RateLimiterResilienceStrategyBuilderExtensionsTests.cs +++ b/src/Polly.RateLimiting.Tests/RateLimiterResilienceStrategyBuilderExtensionsTests.cs @@ -56,7 +56,7 @@ public class RateLimiterResilienceStrategyBuilderExtensionsTests }; [MemberData(nameof(Data))] - [Theory] + [Theory(Skip = "https://github.com/stryker-mutator/stryker-net/issues/2144")] public void AddRateLimiter_Extensions_Ok(Action configure) { var builder = new ResilienceStrategyBuilder(); @@ -66,6 +66,19 @@ public void AddRateLimiter_Extensions_Ok(Action confi builder.Build().Should().BeOfType(); } + [Fact] + public void AddRateLimiter_AllExtensions_Ok() + { + foreach (var configure in Data.Select(v => v[0]).Cast>()) + { + var builder = new ResilienceStrategyBuilder(); + + configure(builder); + + builder.Build().Should().BeOfType(); + } + } + [Fact] public void AddRateLimiter_InvalidOptions_Throws() {