Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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);CA1030;CA1031;CA2008;CA2201</NoWarn>
<NoWarn>$(NoWarn);S103;S104;S2184;S3878;S6966</NoWarn>
<NoWarn>$(NoWarn);S103;S104;S2184;S6966</NoWarn>
<NoWarn>$(NoWarn);SA1204;SA1402;SA1600</NoWarn>
</PropertyGroup>

Expand Down
13 changes: 8 additions & 5 deletions test/Polly.Specs/Wrap/PolicyWrapSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ public void Wrapping_nothing_using_static_wrap_syntax_should_throw()
public void Wrapping_only_one_policy_using_static_wrap_syntax_should_throw()
{
Policy singlePolicy = Policy.Handle<Exception>().Retry();

#pragma warning disable S3878 // Remove this array creation and simply pass the elements
Action config = () => Policy.Wrap(new[] { singlePolicy });
#pragma warning restore S3878

config.Should().Throw<ArgumentException>().And.ParamName.Should().Be("policies");
}
Expand All @@ -263,7 +266,7 @@ public void Wrapping_two_policies_using_static_wrap_syntax_should_not_throw()
{
Policy retry = Policy.Handle<Exception>().Retry();
Policy breaker = Policy.Handle<Exception>().CircuitBreaker(1, TimeSpan.FromSeconds(10));
Action config = () => Policy.Wrap(new[] { retry, breaker });
Action config = () => Policy.Wrap(retry, breaker);

config.Should().NotThrow();
}
Expand All @@ -275,7 +278,7 @@ public void Wrapping_more_than_two_policies_using_static_wrap_syntax_should_not_
Policy divideByZeroRetry = Policy.Handle<DivideByZeroException>().Retry(2);
Policy breaker = Policy.Handle<Exception>().CircuitBreaker(1, TimeSpan.FromSeconds(10));

Action config = () => Policy.Wrap(new[] { divideByZeroRetry, retry, breaker });
Action config = () => Policy.Wrap(divideByZeroRetry, retry, breaker);

config.Should().NotThrow();
}
Expand Down Expand Up @@ -308,7 +311,7 @@ public void Wrapping_nothing_using_static_wrap_strongly_typed_syntax_should_thro
public void Wrapping_only_one_policy_using_static_wrap_strongly_typed_syntax_should_throw()
{
Policy<int> singlePolicy = Policy<int>.Handle<Exception>().Retry();
Action config = () => Policy.Wrap<int>(new[] { singlePolicy });
Action config = () => Policy.Wrap<int>(singlePolicy);

config.Should().Throw<ArgumentException>().And.ParamName.Should().Be("policies");
}
Expand All @@ -318,7 +321,7 @@ public void Wrapping_two_policies_using_static_wrap_strongly_typed_syntax_should
{
Policy<int> retry = Policy<int>.Handle<Exception>().Retry();
Policy<int> breaker = Policy<int>.Handle<Exception>().CircuitBreaker(1, TimeSpan.FromSeconds(10));
Action config = () => Policy.Wrap<int>(new[] { retry, breaker });
Action config = () => Policy.Wrap<int>(retry, breaker);

config.Should().NotThrow();
}
Expand All @@ -330,7 +333,7 @@ public void Wrapping_more_than_two_policies_using_static_wrap_strongly_typed_syn
Policy<int> divideByZeroRetry = Policy<int>.Handle<DivideByZeroException>().Retry(2);
Policy<int> breaker = Policy<int>.Handle<Exception>().CircuitBreaker(1, TimeSpan.FromSeconds(10));

Action config = () => Policy.Wrap<int>(new[] { divideByZeroRetry, retry, breaker });
Action config = () => Policy.Wrap<int>(divideByZeroRetry, retry, breaker);

config.Should().NotThrow();
}
Expand Down
12 changes: 6 additions & 6 deletions test/Polly.Specs/Wrap/PolicyWrapSpecsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void Wrapping_nothing_using_static_wrap_syntax_should_throw()
public void Wrapping_only_one_policy_using_static_wrap_syntax_should_throw()
{
AsyncPolicy singlePolicy = Policy.Handle<Exception>().RetryAsync();
Action config = () => Policy.WrapAsync(new[] { singlePolicy });
Action config = () => Policy.WrapAsync(singlePolicy);

config.Should().Throw<ArgumentException>().And.ParamName.Should().Be("policies");
}
Expand All @@ -263,7 +263,7 @@ public void Wrapping_two_policies_using_static_wrap_syntax_should_not_throw()
{
AsyncPolicy retry = Policy.Handle<Exception>().RetryAsync();
AsyncPolicy breaker = Policy.Handle<Exception>().CircuitBreakerAsync(1, TimeSpan.FromSeconds(10));
Action config = () => Policy.WrapAsync(new[] { retry, breaker });
Action config = () => Policy.WrapAsync(retry, breaker);

config.Should().NotThrow();
}
Expand All @@ -275,7 +275,7 @@ public void Wrapping_more_than_two_policies_using_static_wrap_syntax_should_not_
AsyncPolicy divideByZeroRetry = Policy.Handle<DivideByZeroException>().RetryAsync(2);
AsyncPolicy breaker = Policy.Handle<Exception>().CircuitBreakerAsync(1, TimeSpan.FromSeconds(10));

Action config = () => Policy.WrapAsync(new[] { divideByZeroRetry, retry, breaker });
Action config = () => Policy.WrapAsync(divideByZeroRetry, retry, breaker);

config.Should().NotThrow();
}
Expand Down Expand Up @@ -308,7 +308,7 @@ public void Wrapping_nothing_using_static_wrap_strongly_typed_syntax_should_thro
public void Wrapping_only_one_policy_using_static_wrap_strongly_typed_syntax_should_throw()
{
AsyncPolicy<int> singlePolicy = Policy<int>.Handle<Exception>().RetryAsync();
Action config = () => Policy.WrapAsync<int>(new[] { singlePolicy });
Action config = () => Policy.WrapAsync<int>(singlePolicy);

config.Should().Throw<ArgumentException>().And.ParamName.Should().Be("policies");
}
Expand All @@ -318,7 +318,7 @@ public void Wrapping_two_policies_using_static_wrap_strongly_typed_syntax_should
{
AsyncPolicy<int> retry = Policy<int>.Handle<Exception>().RetryAsync();
AsyncPolicy<int> breaker = Policy<int>.Handle<Exception>().CircuitBreakerAsync(1, TimeSpan.FromSeconds(10));
Action config = () => Policy.WrapAsync<int>(new[] { retry, breaker });
Action config = () => Policy.WrapAsync<int>(retry, breaker);

config.Should().NotThrow();
}
Expand All @@ -330,7 +330,7 @@ public void Wrapping_more_than_two_policies_using_static_wrap_strongly_typed_syn
AsyncPolicy<int> divideByZeroRetry = Policy<int>.Handle<DivideByZeroException>().RetryAsync(2);
AsyncPolicy<int> breaker = Policy<int>.Handle<Exception>().CircuitBreakerAsync(1, TimeSpan.FromSeconds(10));

Action config = () => Policy.WrapAsync<int>(new[] { divideByZeroRetry, retry, breaker });
Action config = () => Policy.WrapAsync<int>(divideByZeroRetry, retry, breaker);

config.Should().NotThrow();
}
Expand Down