diff --git a/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs b/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs index 910037550e4..76e4431c8f7 100644 --- a/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs +++ b/test/Polly.Specs/Wrap/PolicyWrapContextAndKeyAsyncSpecs.cs @@ -192,6 +192,8 @@ public class PolicyWrapTResultContextAndKeyAsyncSpecs { #region PolicyKey and execution Context tests + private static void ThrowException() => throw new Exception(); + [Fact] public async Task Should_pass_PolicyKey_to_execution_context_of_outer_policy_as_PolicyWrapKey() { @@ -296,11 +298,8 @@ public async Task Should_restore_PolicyKey_of_outer_policy_to_execution_context_ await policyWrap.ExecuteAsync(async () => await Task.Run(() => // Regression test for issue 510 { - throw new Exception(); -#pragma warning disable 0162 // unreachable code detected + ThrowException(); return ResultPrimitive.WhateverButTooLate; -#pragma warning restore 0162 - })); }