Skip to content

Commit

Permalink
Remove redundant qualifiers
Browse files Browse the repository at this point in the history
Remove redundant qualifiers from code.
  • Loading branch information
martincostello committed Feb 4, 2024
1 parent 8927e79 commit 34c0d58
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 23 deletions.
11 changes: 3 additions & 8 deletions test/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
namespace Polly.Specs.Bulkhead;

[Collection(Helpers.Constants.ParallelThreadDependentTestCollection)]
public class BulkheadAsyncSpecs : BulkheadSpecsBase
[Collection(Constants.ParallelThreadDependentTestCollection)]
public class BulkheadAsyncSpecs(ITestOutputHelper testOutputHelper) : BulkheadSpecsBase(testOutputHelper)
{
public BulkheadAsyncSpecs(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}

#region Configuration

[Fact]
Expand Down Expand Up @@ -59,7 +54,7 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
{
_ = Task.Run(() => { bulkhead.ExecuteAsync(async () => { await tcs.Task; }); });

Within(CohesionTimeLimit, () => BulkheadSpecsBase.Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));

await bulkhead.Awaiting(b => b.ExecuteAsync(_ => TaskHelper.EmptyTask, contextPassedToExecute)).Should().ThrowAsync<BulkheadRejectedException>();

Expand Down
4 changes: 2 additions & 2 deletions test/Polly.Specs/Bulkhead/BulkheadSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.Bulkhead;

[Collection(Helpers.Constants.ParallelThreadDependentTestCollection)]
[Collection(Constants.ParallelThreadDependentTestCollection)]
public class BulkheadSpecs : BulkheadSpecsBase
{
public BulkheadSpecs(ITestOutputHelper testOutputHelper)
Expand Down Expand Up @@ -59,7 +59,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Task.Run(() => { bulkhead.Execute(() => { tcs.Task.Wait(); }); });

// Time for the other thread to kick up and take the bulkhead.
Within(CohesionTimeLimit, () => BulkheadSpecsBase.Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));

bulkhead.Invoking(b => b.Execute(_ => { }, contextPassedToExecute)).Should()
.Throw<BulkheadRejectedException>();
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.Bulkhead;

[Collection(Helpers.Constants.ParallelThreadDependentTestCollection)]
[Collection(Constants.ParallelThreadDependentTestCollection)]
public abstract class BulkheadSpecsBase : IDisposable
{
#region Time constraints
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
});
});

Within(CohesionTimeLimit, () => BulkheadSpecsBase.Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));

await bulkhead.Awaiting(b => b.ExecuteAsync(_ => Task.FromResult(1), contextPassedToExecute)).Should().ThrowAsync<BulkheadRejectedException>();

Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
});
});

Within(CohesionTimeLimit, () => BulkheadSpecsBase.Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));

bulkhead.Invoking(b => b.Execute(_ => 1, contextPassedToExecute)).Should().Throw<BulkheadRejectedException>();

Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/RateLimit/AsyncRateLimitPolicySpecs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.RateLimit;

[Collection(Polly.Specs.Helpers.Constants.SystemClockDependentTestCollection)]
[Collection(Constants.SystemClockDependentTestCollection)]
public class AsyncRateLimitPolicySpecs : RateLimitPolicySpecsBase, IDisposable
{
public void Dispose() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.RateLimit;

[Collection(Polly.Specs.Helpers.Constants.SystemClockDependentTestCollection)]
[Collection(Constants.SystemClockDependentTestCollection)]
public class AsyncRateLimitPolicyTResultSpecs : RateLimitPolicyTResultSpecsBase, IDisposable
{
public void Dispose() =>
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/RateLimit/RateLimitPolicySpecs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.RateLimit;

[Collection(Polly.Specs.Helpers.Constants.SystemClockDependentTestCollection)]
[Collection(Constants.SystemClockDependentTestCollection)]
public class RateLimitPolicySpecs : RateLimitPolicySpecsBase, IDisposable
{
public void Dispose() =>
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/RateLimit/RateLimitPolicySpecsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
// Act - release gate.
gate.Set();
#pragma warning disable S6603
RateLimitSpecsBase.Within(TimeSpan.FromSeconds(10 /* high to allow for slow-running on time-slicing CI servers */), () => tasks.All(t => t.IsCompleted).Should().BeTrue());
Within(TimeSpan.FromSeconds(10 /* high to allow for slow-running on time-slicing CI servers */), () => tasks.All(t => t.IsCompleted).Should().BeTrue());
#pragma warning restore S6603

// Assert - one should have permitted execution, n-1 not.
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/RateLimit/RateLimitPolicyTResultSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.RateLimit;

[Collection(Polly.Specs.Helpers.Constants.SystemClockDependentTestCollection)]
[Collection(Constants.SystemClockDependentTestCollection)]
public class RateLimitPolicyTResultSpecs : RateLimitPolicyTResultSpecsBase, IDisposable
{
public void Dispose() =>
Expand Down
4 changes: 2 additions & 2 deletions test/Polly.Specs/RateLimit/TokenBucketRateLimiterTestsBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Specs.RateLimit;

[Collection(Polly.Specs.Helpers.Constants.SystemClockDependentTestCollection)]
[Collection(Constants.SystemClockDependentTestCollection)]
public abstract class TokenBucketRateLimiterTestsBase : RateLimitSpecsBase, IDisposable
{
internal abstract IRateLimiter GetRateLimiter(TimeSpan onePer, long bucketCapacity);
Expand Down Expand Up @@ -194,7 +194,7 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
// Act - release gate.
gate.Set();
#pragma warning disable S6603
RateLimitSpecsBase.Within(TimeSpan.FromSeconds(10 /* high to allow for slow-running on time-slicing CI servers */), () => tasks.All(t => t.IsCompleted).Should().BeTrue());
Within(TimeSpan.FromSeconds(10 /* high to allow for slow-running on time-slicing CI servers */), () => tasks.All(t => t.IsCompleted).Should().BeTrue());
#pragma warning restore S6603

// Assert - one should have permitted execution, n-1 not.
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Timeout/TimeoutSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void Should_rethrow_aggregate_exception_from_inside_delegate__pessimistic
// Check to see if nested aggregate exceptions are unwrapped correctly
AggregateException exception = new AggregateException(msg, new NotImplementedException());

policy.Invoking(p => p.Execute(() => { TimeoutSpecsBase.Helper_ThrowException(exception); }))
policy.Invoking(p => p.Execute(() => { Helper_ThrowException(exception); }))
.Should().Throw<AggregateException>()
.WithMessage(exception.Message)
.Where(e => e.InnerException is NotImplementedException)
Expand Down
4 changes: 2 additions & 2 deletions test/Polly.Specs/Timeout/TimeoutTResultSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void Should_rethrow_aggregate_exception_from_inside_delegate__pessimistic
// Check to see if nested aggregate exceptions are unwrapped correctly
AggregateException exception = new AggregateException(msg, new NotImplementedException());

policy.Invoking(p => p.Execute(() => { TimeoutSpecsBase.Helper_ThrowException(exception); return ResultPrimitive.WhateverButTooLate; }))
policy.Invoking(p => p.Execute(() => { Helper_ThrowException(exception); return ResultPrimitive.WhateverButTooLate; }))
.Should().Throw<AggregateException>()
.WithMessage(exception.Message)
.Where(e => e.InnerException is NotImplementedException)
Expand All @@ -278,7 +278,7 @@ public void Should_rethrow_aggregate_exception_with_multiple_exceptions_from_ins
Exception innerException1 = new NotImplementedException();
Exception innerException2 = new DivideByZeroException();
AggregateException aggregateException = new AggregateException(msg, innerException1, innerException2);
Func<ResultPrimitive> func = () => { TimeoutSpecsBase.Helper_ThrowException(aggregateException); return ResultPrimitive.WhateverButTooLate; };
Func<ResultPrimitive> func = () => { Helper_ThrowException(aggregateException); return ResultPrimitive.WhateverButTooLate; };

// Whether executing the delegate directly, or through the policy, exception behavior should be the same.
func.Should().Throw<AggregateException>()
Expand Down

0 comments on commit 34c0d58

Please sign in to comment.