Skip to content

Commit

Permalink
Merge pull request #997 from App-vNext/remove-some-trailing-whitespace
Browse files Browse the repository at this point in the history
remove some trailing whitespace
  • Loading branch information
SimonCropp authored Jan 7, 2023
2 parents 22bd1ff + db695f9 commit 03d9849
Show file tree
Hide file tree
Showing 81 changed files with 276 additions and 276 deletions.
2 changes: 1 addition & 1 deletion src/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
Func<Context, Task> onRejectedAsync = async ctx => { contextPassedToOnRejected = ctx; await TaskHelper.EmptyTask; };

using (var bulkhead = Policy.BulkheadAsync<int>(1, onRejectedAsync))
{
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
using (CancellationTokenSource cancellationSource = new CancellationTokenSource())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Action<Context> onRejected = ctx => { contextPassedToOnRejected = ctx; };

using (BulkheadPolicy<int> bulkhead = Policy.Bulkhead<int>(1, onRejected))
{
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
using (CancellationTokenSource cancellationSource = new CancellationTokenSource())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Polly.Specs.Caching;

public class AsyncSerializingCacheProviderSpecs
{
#region Object-to-TSerialized serializer
#region Object-to-TSerialized serializer

[Fact]
public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider()
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Specs/Caching/SerializingCacheProviderSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Polly.Specs.Caching;

public class SerializingCacheProviderSpecs
{
#region Object-to-TSerialized serializer
#region Object-to-TSerialized serializer

[Fact]
public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider()
Expand Down
46 changes: 23 additions & 23 deletions src/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public void Should_throw_if_timeslice_duration_is_less_than_resolution_of_circui
Action action = () => Policy
.Handle<DivideByZeroException>()
.AdvancedCircuitBreaker(
0.5,
TimeSpan.FromMilliseconds(20).Add(TimeSpan.FromTicks(-1)),
4,
0.5,
TimeSpan.FromMilliseconds(20).Add(TimeSpan.FromTicks(-1)),
4,
TimeSpan.FromSeconds(30));

action.Should().Throw<ArgumentOutOfRangeException>()
Expand Down Expand Up @@ -164,8 +164,8 @@ public void Should_initialise_to_closed_state()

#region Tests that are independent from health metrics implementation

// Tests on the AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// Tests on the AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// - and a throughput threshold of 4
// - across a ten-second period.
// These provide easy values for testing for failure and throughput thresholds each being met and non-met, in combination.
Expand Down Expand Up @@ -244,8 +244,8 @@ public void Should_not_open_circuit_if_exceptions_raised_are_not_one_of_the_spec

#region With sample duration higher than 199 ms so that multiple windows are used

// Tests on the AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// Tests on the AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// - and a throughput threshold of 4
// - across a ten-second period.
// These provide easy values for testing for failure and throughput thresholds each being met and non-met, in combination.
Expand Down Expand Up @@ -838,8 +838,8 @@ public void Should_not_open_circuit_if_failures_at_end_of_last_timeslice_and_fai
// Setting the time to just barely into the new timeslice
SystemClock.UtcNow = () => time.Add(samplingDuration);

// A third failure occurs just at the beginning of the new timeslice making
// the number of failures above the failure threshold. However, the throughput is
// A third failure occurs just at the beginning of the new timeslice making
// the number of failures above the failure threshold. However, the throughput is
// below the minimum threshold as to open the circuit.
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();
Expand Down Expand Up @@ -898,8 +898,8 @@ public void Should_open_circuit_if_failures_in_second_window_of_last_timeslice_a

#region With sample duration at 199 ms so that only a single window is used

// These tests on AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// These tests on AdvancedCircuitBreaker operation typically use a breaker:
// - with a failure threshold of >=50%,
// - and a throughput threshold of 4
// - across a 199ms period.
// These provide easy values for testing for failure and throughput thresholds each being met and non-met, in combination.
Expand Down Expand Up @@ -1258,7 +1258,7 @@ public void Should_not_open_circuit_if_failures_at_end_of_last_timeslice_below_f
// Setting the time to just barely into the new timeslice
SystemClock.UtcNow = () => time.Add(samplingDuration);

// This failure does not open the circuit, because a new duration should have
// This failure does not open the circuit, because a new duration should have
// started and with such low sampling duration, windows should not be used.
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();
Expand Down Expand Up @@ -1413,7 +1413,7 @@ public void Should_open_circuit_again_after_the_specified_duration_has_passed_if
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();
breaker.CircuitState.Should().Be(CircuitState.Open);

}

[Fact]
Expand Down Expand Up @@ -1483,7 +1483,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -1522,7 +1522,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -1569,7 +1569,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exceptions raised, circuit is now open.
// exceptions raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand All @@ -1582,7 +1582,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
TimeSpan testTimeoutToExposeDeadlocks = TimeSpan.FromSeconds(5);
using (ManualResetEvent permitSecondExecutionAttempt = new ManualResetEvent(false))
using (ManualResetEvent permitFirstExecutionEnd = new ManualResetEvent(false))
{
{
bool? firstDelegateExecutedInHalfOpenState = null;
bool? secondDelegateExecutedInHalfOpenState = null;
bool? secondDelegateRejectedInHalfOpenState = null;
Expand Down Expand Up @@ -1642,7 +1642,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should not have been permitted.
// - Second execution attempt should have been rejected with HalfOpen state as cause.
Expand Down Expand Up @@ -1674,7 +1674,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand All @@ -1688,7 +1688,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
TimeSpan testTimeoutToExposeDeadlocks = TimeSpan.FromSeconds(5);
using (ManualResetEvent permitSecondExecutionAttempt = new ManualResetEvent(false))
using (ManualResetEvent permitFirstExecutionEnd = new ManualResetEvent(false))
{
{
bool? firstDelegateExecutedInHalfOpenState = null;
bool? secondDelegateExecutedInHalfOpenState = null;
bool? secondDelegateRejectedInHalfOpenState = null;
Expand Down Expand Up @@ -1750,7 +1750,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should have been permitted, one breakDuration later.
firstDelegateExecutedInHalfOpenState.Should().BeTrue();
Expand Down Expand Up @@ -1997,7 +1997,7 @@ public void Should_call_onbreak_when_breaking_circuit_first_time_but_not_for_sub

onBreakCalled.Should().Be(1);

// call through circuit when already broken - should not retrigger onBreak
// call through circuit when already broken - should not retrigger onBreak
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<BrokenCircuitException>();

Expand Down Expand Up @@ -2491,7 +2491,7 @@ public void Should_open_circuit_with_timespan_maxvalue_if_manual_override_open()

var time = 1.January(2000);
SystemClock.UtcNow = () => time;

CircuitBreakerPolicy breaker = Policy
.Handle<DivideByZeroException>()
.AdvancedCircuitBreaker(
Expand Down
16 changes: 8 additions & 8 deletions src/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public async Task Should_only_allow_single_execution_on_first_entering_halfopen_
await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
.Should().ThrowAsync<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -355,13 +355,13 @@ public async Task Should_allow_single_execution_per_break_duration_in_halfopen_s
await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
.Should().ThrowAsync<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
SystemClock.UtcNow = () => time.Add(durationOfBreak);
breaker.CircuitState.Should().Be(CircuitState.HalfOpen);


// OnActionPreExecute() should permit first execution.
breaker._breakerController.Invoking(c => c.OnActionPreExecute()).Should().NotThrow();
Expand Down Expand Up @@ -394,7 +394,7 @@ public async Task Should_only_allow_single_execution_on_first_entering_halfopen_
await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
.Should().ThrowAsync<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -469,7 +469,7 @@ await breaker.ExecuteAsync(async () =>
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should not have been permitted.
// - Second execution attempt should have been rejected with HalfOpen state as cause.
Expand All @@ -493,7 +493,7 @@ public async Task Should_allow_single_execution_per_break_duration_in_halfopen_s
await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
.Should().ThrowAsync<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -571,7 +571,7 @@ await breaker.ExecuteAsync(async () =>
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should have been permitted, one breakDuration later.
firstDelegateExecutedInHalfOpenState.Should().BeTrue();
Expand Down Expand Up @@ -772,7 +772,7 @@ await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
breaker.CircuitState.Should().Be(CircuitState.Open);
onBreakCalled.Should().Be(1);

// call through circuit when already broken - should not retrigger onBreak
// call through circuit when already broken - should not retrigger onBreak
await breaker.Awaiting(x => x.RaiseExceptionAsync<DivideByZeroException>())
.Should().ThrowAsync<BrokenCircuitException>();

Expand Down
22 changes: 11 additions & 11 deletions src/Polly.Specs/CircuitBreaker/CircuitBreakerSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void Should_open_circuit_again_after_the_specified_duration_has_passed_if
breaker.CircuitState.Should().Be(CircuitState.Open);
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<BrokenCircuitException>();

}

[Fact]
Expand Down Expand Up @@ -322,7 +322,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -353,7 +353,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -392,7 +392,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand All @@ -405,7 +405,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
TimeSpan testTimeoutToExposeDeadlocks = TimeSpan.FromSeconds(5);
using (ManualResetEvent permitSecondExecutionAttempt = new ManualResetEvent(false))
using (ManualResetEvent permitFirstExecutionEnd = new ManualResetEvent(false))
{
{
bool? firstDelegateExecutedInHalfOpenState = null;
bool? secondDelegateExecutedInHalfOpenState = null;
bool? secondDelegateRejectedInHalfOpenState = null;
Expand Down Expand Up @@ -465,7 +465,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should not have been permitted.
// - Second execution attempt should have been rejected with HalfOpen state as cause.
Expand All @@ -490,7 +490,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<DivideByZeroException>();

// exception raised, circuit is now open.
// exception raised, circuit is now open.
breaker.CircuitState.Should().Be(CircuitState.Open);

// break duration passes, circuit now half open
Expand Down Expand Up @@ -566,7 +566,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
firstExecution.Status.Should().Be(TaskStatus.RanToCompletion);
secondExecution.Status.Should().Be(TaskStatus.RanToCompletion);

// Assert:
// Assert:
// - First execution should have been permitted and executed under a HalfOpen state
// - Second overlapping execution in halfopen state should have been permitted, one breakDuration later.
firstDelegateExecutedInHalfOpenState.Should().BeTrue();
Expand Down Expand Up @@ -766,7 +766,7 @@ public void Should_call_onbreak_when_breaking_circuit_first_time_but_not_for_sub
breaker.CircuitState.Should().Be(CircuitState.Open);
onBreakCalled.Should().Be(1);

// call through circuit when already broken - should not retrigger onBreak
// call through circuit when already broken - should not retrigger onBreak
breaker.Invoking(x => x.RaiseException<DivideByZeroException>())
.Should().Throw<BrokenCircuitException>();

Expand All @@ -789,7 +789,7 @@ public void Should_call_onbreak_when_breaking_circuit_first_time_but_not_for_sub
TimeSpan testTimeoutToExposeDeadlocks = TimeSpan.FromSeconds(5);
using (ManualResetEvent permitLongRunningExecutionToReturnItsFailure = new ManualResetEvent(false))
using (ManualResetEvent permitMainThreadToOpenCircuit = new ManualResetEvent(false))
{
{
Task longRunningExecution = Task.Factory.StartNew(() =>
{
breaker.CircuitState.Should().Be(CircuitState.Closed);
Expand Down Expand Up @@ -833,7 +833,7 @@ public void Should_call_onbreak_when_breaking_circuit_first_time_but_not_for_sub
}

[Fact]
public void Should_call_onreset_when_automatically_closing_circuit_but_not_when_halfopen()
public void Should_call_onreset_when_automatically_closing_circuit_but_not_when_halfopen()
{
int onBreakCalled = 0;
int onResetCalled = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void Should_open_circuit_with_the_last_handled_result_after_specified_num

breaker.CircuitState.Should().Be(CircuitState.Open);
}

[Fact]
public void Should_not_open_circuit_if_result_raised_or_exception_thrown_is_not_one_of_the_handled_results_or_exceptions()
{
Expand Down
Loading

0 comments on commit 03d9849

Please sign in to comment.