Skip to content

Commit

Permalink
Fix S4144 (remove duplicate tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
gintsk committed Jan 27, 2024
1 parent 57ea75b commit 317b244
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
28 changes: 0 additions & 28 deletions test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CancellationToken, Task<ResultPrimitive>> fallbackAction = _ => Task.FromResult(ResultPrimitive.Substitute);
Func<DelegateResult<ResultPrimitive>, Task> onFallbackAsync = null!;

Action policy = () => Policy
.HandleResult(ResultPrimitive.Fault)
.FallbackAsync(fallbackAction, onFallbackAsync);

policy.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("onFallbackAsync");
}

[Fact]
public void Should_throw_when_onFallback_delegate_is_null_with_context()
{
Expand All @@ -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<Context, CancellationToken, Task<ResultPrimitive>> fallbackAction = (_, _) => Task.FromResult(ResultPrimitive.Substitute);
Func<DelegateResult<ResultPrimitive>, Context, Task> onFallbackAsync = null!;

Action policy = () => Policy
.HandleResult(ResultPrimitive.Fault)
.FallbackAsync(fallbackAction, onFallbackAsync);

policy.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("onFallbackAsync");
}

#endregion

#region Policy operation tests
Expand Down
12 changes: 0 additions & 12 deletions test/Polly.Specs/PolicyTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentNullException>();
ex.And.ParamName.Should().Be("context");
}

[Fact]
public async Task Executing_the_policy_function_should_pass_context_to_executed_delegate()
{
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Polly.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Include>[Polly]*</Include>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;CA2008;CA1806;CA2201;</NoWarn>
<NoWarn>$(NoWarn);S3878;CA1030;S4144;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031</NoWarn>
<NoWarn>$(NoWarn);S3878;CA1030;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031</NoWarn>
<NoWarn>$(NoWarn);S2184;</NoWarn>
</PropertyGroup>

Expand Down

0 comments on commit 317b244

Please sign in to comment.