From 5b7791c7b19aa9fb45027e07342463d65203c851 Mon Sep 17 00:00:00 2001
From: gintsk <3540004+gintsk@users.noreply.github.com>
Date: Sat, 27 Jan 2024 15:58:11 +0200
Subject: [PATCH 1/3] Remove redundand SA1602
---
test/Polly.Core.Tests/Polly.Core.Tests.csproj | 2 +-
test/Polly.Specs/Polly.Specs.csproj | 2 +-
test/Polly.TestUtils/Polly.TestUtils.csproj | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/Polly.Core.Tests/Polly.Core.Tests.csproj b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
index 3a56ef265ad..e169290e2df 100644
--- a/test/Polly.Core.Tests/Polly.Core.Tests.csproj
+++ b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
@@ -5,7 +5,7 @@
Test
enable
100
- $(NoWarn);SA1600;SA1204;SA1602;S6608
+ $(NoWarn);SA1600;SA1204;S6608
[Polly.Core]*
true
diff --git a/test/Polly.Specs/Polly.Specs.csproj b/test/Polly.Specs/Polly.Specs.csproj
index c69d15f0651..25d94804a3c 100644
--- a/test/Polly.Specs/Polly.Specs.csproj
+++ b/test/Polly.Specs/Polly.Specs.csproj
@@ -8,7 +8,7 @@
75,60,70
[Polly]*
true
- $(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;SA1602;CA2008;CA1806;CA2201;
+ $(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;CA2008;CA1806;CA2201;
$(NoWarn);S3878;CA1030;S4144;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031
$(NoWarn);S2184;
diff --git a/test/Polly.TestUtils/Polly.TestUtils.csproj b/test/Polly.TestUtils/Polly.TestUtils.csproj
index 66f550f0165..28fed5ec0e8 100644
--- a/test/Polly.TestUtils/Polly.TestUtils.csproj
+++ b/test/Polly.TestUtils/Polly.TestUtils.csproj
@@ -4,7 +4,7 @@
$(TargetFrameworks);net481
Library
enable
- $(NoWarn);SA1600;SA1204;SA1602;CA1062
+ $(NoWarn);SA1600;SA1204;CA1062
false
false
false
From 57ea75b16434df6f1ec13f207ecfea5ba904adef Mon Sep 17 00:00:00 2001
From: gintsk <3540004+gintsk@users.noreply.github.com>
Date: Sat, 27 Jan 2024 16:22:36 +0200
Subject: [PATCH 2/3] Fix S6608 (net481 style)
---
test/Polly.Core.Tests/Polly.Core.Tests.csproj | 2 +-
test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs | 4 ++--
test/Polly.Core.Tests/Utils/ObjectPoolTests.cs | 2 +-
test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj | 2 +-
.../ReloadableResiliencePipelineTests.cs | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/Polly.Core.Tests/Polly.Core.Tests.csproj b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
index e169290e2df..b982b9b6add 100644
--- a/test/Polly.Core.Tests/Polly.Core.Tests.csproj
+++ b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
@@ -5,7 +5,7 @@
Test
enable
100
- $(NoWarn);SA1600;SA1204;S6608
+ $(NoWarn);SA1600;SA1204
[Polly.Core]*
true
diff --git a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
index 0a94d396896..6e5a4717398 100644
--- a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
+++ b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
@@ -89,9 +89,9 @@ public void ExecuteAsync_MultipleRetries_EnsureDiscardedResultsDisposed()
// assert
result.IsDisposed.Should().BeFalse();
results.Count.Should().Be(_options.MaxRetryAttempts + 1);
- results.Last().IsDisposed.Should().BeFalse();
+ results[results.Count - 1].IsDisposed.Should().BeFalse();
- results.Remove(results.Last());
+ results.Remove(results[results.Count - 1]);
results.Should().AllSatisfy(r => r.IsDisposed.Should().BeTrue());
}
diff --git a/test/Polly.Core.Tests/Utils/ObjectPoolTests.cs b/test/Polly.Core.Tests/Utils/ObjectPoolTests.cs
index b9383df28c9..eb5d46e195b 100644
--- a/test/Polly.Core.Tests/Utils/ObjectPoolTests.cs
+++ b/test/Polly.Core.Tests/Utils/ObjectPoolTests.cs
@@ -52,7 +52,7 @@ public void MaxCapacityOverflow_Respected()
var items2 = GetStoreReturn(pool, count);
// Assert
- items1.Last().Should().NotBeSameAs(items2.Last());
+ items1[items1.Count - 1].Should().NotBeSameAs(items2[items2.Count - 1]);
}
[Fact]
diff --git a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
index b33283d0398..c45f7a77232 100644
--- a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
+++ b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
@@ -5,7 +5,7 @@
Test
enable
100
- $(NoWarn);SA1600;SA1204;S6608
+ $(NoWarn);SA1600;SA1204
[Polly.Extensions]*
diff --git a/test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs b/test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs
index 6546ee3a2e6..547fc1db61f 100644
--- a/test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs
+++ b/test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs
@@ -74,11 +74,11 @@ public void AddResiliencePipeline_EnsureReloadable(string? name)
resList[i].Received(1).Dispose();
}
- resList.Last().Received(0).Dispose();
+ resList[resList.Count - 1].Received(0).Dispose();
// check disposal of service provider
serviceProvider.Dispose();
- resList.Last().Received(1).Dispose();
+ resList[resList.Count - 1].Received(1).Dispose();
pipeline.Invoking(p => p.Execute(() => { })).Should().Throw();
foreach (var ev in fakeListener.Events)
From 317b2448c28139058ef535f58407ab762b5b9c15 Mon Sep 17 00:00:00 2001
From: gintsk <3540004+gintsk@users.noreply.github.com>
Date: Sat, 27 Jan 2024 17:18:35 +0200
Subject: [PATCH 3/3] Fix S4144 (remove duplicate tests)
---
.../Fallback/FallbackTResultAsyncSpecs.cs | 28 -------------------
test/Polly.Specs/PolicyTResultAsyncSpecs.cs | 12 --------
test/Polly.Specs/Polly.Specs.csproj | 2 +-
3 files changed, 1 insertion(+), 41 deletions(-)
diff --git a/test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs b/test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs
index 618d7cd336c..45350dde783 100644
--- a/test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs
+++ b/test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs
@@ -61,20 +61,6 @@ public void Should_throw_when_onFallback_delegate_is_null()
.And.ParamName.Should().Be("onFallbackAsync");
}
- [Fact]
- public void Should_throw_when_onFallback_delegate_is_null_with_action_with_cancellation()
- {
- Func> fallbackAction = _ => Task.FromResult(ResultPrimitive.Substitute);
- Func, Task> onFallbackAsync = null!;
-
- Action policy = () => Policy
- .HandleResult(ResultPrimitive.Fault)
- .FallbackAsync(fallbackAction, onFallbackAsync);
-
- policy.Should().Throw()
- .And.ParamName.Should().Be("onFallbackAsync");
- }
-
[Fact]
public void Should_throw_when_onFallback_delegate_is_null_with_context()
{
@@ -89,20 +75,6 @@ public void Should_throw_when_onFallback_delegate_is_null_with_context()
.And.ParamName.Should().Be("onFallbackAsync");
}
- [Fact]
- public void Should_throw_when_onFallback_delegate_is_null_with_context_with_action_with_cancellation()
- {
- Func> fallbackAction = (_, _) => Task.FromResult(ResultPrimitive.Substitute);
- Func, Context, Task> onFallbackAsync = null!;
-
- Action policy = () => Policy
- .HandleResult(ResultPrimitive.Fault)
- .FallbackAsync(fallbackAction, onFallbackAsync);
-
- policy.Should().Throw()
- .And.ParamName.Should().Be("onFallbackAsync");
- }
-
#endregion
#region Policy operation tests
diff --git a/test/Polly.Specs/PolicyTResultAsyncSpecs.cs b/test/Polly.Specs/PolicyTResultAsyncSpecs.cs
index 5b88db91271..18957deb20f 100644
--- a/test/Polly.Specs/PolicyTResultAsyncSpecs.cs
+++ b/test/Polly.Specs/PolicyTResultAsyncSpecs.cs
@@ -110,18 +110,6 @@ public async Task Executing_the_policy_function_should_throw_when_context_is_nul
ex.And.ParamName.Should().Be("context");
}
- [Fact]
- public async Task Execute_and_capturing_the_policy_function_should_throw_when_context_data_is_null()
- {
- var policy = Policy
- .HandleResult(ResultPrimitive.Fault)
- .RetryAsync((_, _, _) => { });
-
- var ex = await policy.Awaiting(p => p.ExecuteAndCaptureAsync(_ => Task.FromResult(ResultPrimitive.Good), null!))
- .Should().ThrowAsync();
- ex.And.ParamName.Should().Be("context");
- }
-
[Fact]
public async Task Executing_the_policy_function_should_pass_context_to_executed_delegate()
{
diff --git a/test/Polly.Specs/Polly.Specs.csproj b/test/Polly.Specs/Polly.Specs.csproj
index 25d94804a3c..737cab0336b 100644
--- a/test/Polly.Specs/Polly.Specs.csproj
+++ b/test/Polly.Specs/Polly.Specs.csproj
@@ -9,7 +9,7 @@
[Polly]*
true
$(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;CA2008;CA1806;CA2201;
- $(NoWarn);S3878;CA1030;S4144;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031
+ $(NoWarn);S3878;CA1030;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031
$(NoWarn);S2184;