Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unstable tests #1115

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Polly.Core.Tests/ResilienceStrategyTests.Async.Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ private static IEnumerable<ExecuteParameters> 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"))
Expand All @@ -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();
}

Expand Down
4 changes: 0 additions & 4 deletions src/Polly.Core.Tests/ResilienceStrategyTests.Async.TaskT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ private static IEnumerable<ExecuteParameters> ExecuteAsTaskAsyncT_EnsureCorrectB
{
Caption = "ExecuteAsTaskAsyncT_NoCancellation",
AssertContext = AssertResilienceContext,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.ExecuteTaskAsync(async t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result)
{
Caption = "ExecuteAsTaskAsyncT_Cancellation",
AssertContext = AssertResilienceContextAndToken,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.ExecuteTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result)
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ private static IEnumerable<ExecuteParameters> 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"))
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ private static IEnumerable<ExecuteParameters> ExecuteAsyncT_EnsureCorrectBehavio
{
Caption = "ExecuteAsyncT_NoCancellation",
AssertContext = AssertResilienceContext,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.ExecuteValueTaskAsync(async t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result)
{
Caption = "ExecuteAsyncT_Cancellation",
AssertContext = AssertResilienceContextAndToken,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.ExecuteValueTaskAsync(async (_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result)
Expand All @@ -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();
}

Expand Down
4 changes: 0 additions & 4 deletions src/Polly.Core.Tests/ResilienceStrategyTests.Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ private static IEnumerable<ExecuteParameters> 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"))
Expand All @@ -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();
}

Expand Down
4 changes: 0 additions & 4 deletions src/Polly.Core.Tests/ResilienceStrategyTests.SyncT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ private static IEnumerable<ExecuteParameters> ExecuteT_EnsureCorrectBehavior_Exe
{
Caption = "ExecuteT_NoCancellation",
AssertContext = AssertResilienceContext,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.Execute(t => { t.Should().Be(CancellationToken); return result; }, CancellationToken), result)
{
Caption = "ExecuteT_Cancellation",
AssertContext = AssertResilienceContextAndToken,
AssertContextAfter = AssertContextNotInitialized,
};

yield return new ExecuteParameters<long>(r => r.Execute((_, s) => { s.Should().Be("dummy-state"); return result; }, ResilienceContext.Get(), "dummy-state"), result)
Expand All @@ -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();
}

Expand Down