diff --git a/eng/Test.targets b/eng/Test.targets
index cefc8e70e7..e80cc4b30b 100644
--- a/eng/Test.targets
+++ b/eng/Test.targets
@@ -6,6 +6,7 @@
+
@@ -15,6 +16,7 @@
+
diff --git a/test/Polly.Core.Tests/Polly.Core.Tests.csproj b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
index dd5681d5a5..bceada5ec7 100644
--- a/test/Polly.Core.Tests/Polly.Core.Tests.csproj
+++ b/test/Polly.Core.Tests/Polly.Core.Tests.csproj
@@ -15,7 +15,6 @@
-
@@ -31,6 +30,5 @@
-
diff --git a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
index 914fb1c13c..7db495410f 100644
--- a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
+++ b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj
@@ -15,13 +15,11 @@
-
-
diff --git a/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj b/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj
index 127282bb40..23cf116606 100644
--- a/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj
+++ b/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj
@@ -16,9 +16,5 @@
-
-
-
-
diff --git a/test/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs b/test/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs
index 1ae18c9dbb..4417d3598e 100644
--- a/test/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs
+++ b/test/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs
@@ -27,10 +27,10 @@ public void Should_throw_when_action_is_null()
var func = () => generic.Invoke(instance, [action, new Context(), CancellationToken, false]);
- var exceptionAssertions = func.Should().Throw();
- exceptionAssertions.And.Message.Should().Be("Exception has been thrown by the target of an invocation.");
- exceptionAssertions.And.InnerException.Should().BeOfType()
- .Which.ParamName.Should().Be("action");
+ var exceptionAssertions = Should.Throw(func);
+ exceptionAssertions.Message.ShouldBe("Exception has been thrown by the target of an invocation.");
+ exceptionAssertions.InnerException.ShouldBeOfType()
+ .ParamName.ShouldBe("action");
}
[Fact]
@@ -39,8 +39,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero_and_no_ma
Action policy = () => Policy
.BulkheadAsync(0);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -49,8 +49,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero()
Action policy = () => Policy
.BulkheadAsync(0, 1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -59,8 +59,8 @@ public void Should_throw_when_maxQueuingActions_less_than_zero()
Action policy = () => Policy
.BulkheadAsync(1, -1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxQueuingActions");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxQueuingActions");
}
[Fact]
@@ -69,8 +69,8 @@ public void Should_throw_when_onBulkheadRejected_is_null()
Action policy = () => Policy
.BulkheadAsync(1, 0, null!);
- policy.Should().Throw().And
- .ParamName.Should().Be("onBulkheadRejectedAsync");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("onBulkheadRejectedAsync");
}
#endregion
@@ -94,7 +94,8 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
- await bulkhead.Awaiting(b => b.ExecuteAsync(_ => TaskHelper.EmptyTask, contextPassedToExecute)).Should().ThrowAsync();
+ await Should.ThrowAsync(
+ () => bulkhead.ExecuteAsync(_ => TaskHelper.EmptyTask, contextPassedToExecute));
cancellationSource.Cancel();
@@ -105,9 +106,9 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
#endif
}
- contextPassedToOnRejected!.Should().NotBeNull();
- contextPassedToOnRejected!.OperationKey.Should().Be(operationKey);
- contextPassedToOnRejected!.Should().BeSameAs(contextPassedToExecute);
+ contextPassedToOnRejected!.ShouldNotBeNull();
+ contextPassedToOnRejected!.OperationKey.ShouldBe(operationKey);
+ contextPassedToOnRejected!.ShouldBeSameAs(contextPassedToExecute);
}
#endregion
diff --git a/test/Polly.Specs/Bulkhead/BulkheadSpecs.cs b/test/Polly.Specs/Bulkhead/BulkheadSpecs.cs
index ca443a9466..3d9b77e3dc 100644
--- a/test/Polly.Specs/Bulkhead/BulkheadSpecs.cs
+++ b/test/Polly.Specs/Bulkhead/BulkheadSpecs.cs
@@ -32,10 +32,10 @@ public void Should_throw_when_action_is_null()
var func = () => generic.Invoke(instance, [action, new Context(), CancellationToken]);
- var exceptionAssertions = func.Should().Throw();
- exceptionAssertions.And.Message.Should().Be("Exception has been thrown by the target of an invocation.");
- exceptionAssertions.And.InnerException.Should().BeOfType()
- .Which.ParamName.Should().Be("action");
+ var exceptionAssertions = Should.Throw(func);
+ exceptionAssertions.Message.ShouldBe("Exception has been thrown by the target of an invocation.");
+ exceptionAssertions.InnerException.ShouldBeOfType()
+ .ParamName.ShouldBe("action");
}
[Fact]
@@ -44,8 +44,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero_and_no_ma
Action policy = () => Policy
.Bulkhead(0);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -54,8 +54,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero()
Action policy = () => Policy
.Bulkhead(0, 1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -64,8 +64,8 @@ public void Should_throw_when_maxQueuedActions_less_than_zero()
Action policy = () => Policy
.Bulkhead(1, -1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxQueuingActions");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxQueuingActions");
}
[Fact]
@@ -74,8 +74,8 @@ public void Should_throw_when_onBulkheadRejected_is_null()
Action policy = () => Policy
.Bulkhead(1, 0, null!);
- policy.Should().Throw().And
- .ParamName.Should().Be("onBulkheadRejected");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("onBulkheadRejected");
}
#endregion
@@ -99,8 +99,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
// Time for the other thread to kick up and take the bulkhead.
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
- bulkhead.Invoking(b => b.Execute(_ => { }, contextPassedToExecute)).Should()
- .Throw();
+ Should.Throw(() => bulkhead.Execute(_ => { }, contextPassedToExecute));
#if NET
tcs.SetCanceled(CancellationToken);
@@ -108,9 +107,9 @@ public void Should_call_onBulkheadRejected_with_passed_context()
tcs.SetCanceled();
#endif
- contextPassedToOnRejected!.Should().NotBeNull();
- contextPassedToOnRejected!.OperationKey.Should().Be(operationKey);
- contextPassedToOnRejected!.Should().BeSameAs(contextPassedToExecute);
+ contextPassedToOnRejected!.ShouldNotBeNull();
+ contextPassedToOnRejected!.OperationKey.ShouldBe(operationKey);
+ contextPassedToOnRejected!.ShouldBeSameAs(contextPassedToExecute);
}
#endregion
diff --git a/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs b/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs
index d8b0244238..a7570fa40d 100644
--- a/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs
+++ b/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs
@@ -334,7 +334,7 @@ protected void Within(TimeSpan timeSpan, Func actionContainin
if (watch.Elapsed > permitted)
{
TestOutputHelper.WriteLine("Failing assertion on: {0}", potentialFailure.Measure);
- potentialFailure.Actual.Should().Be(potentialFailure.Expected, $"for '{potentialFailure.Measure}', in scenario: {Scenario}");
+ potentialFailure.Actual.ShouldBe(potentialFailure.Expected, $"for '{potentialFailure.Measure}', in scenario: {Scenario}");
throw new InvalidOperationException("Code should never reach here. Preceding assertion should fail.");
}
diff --git a/test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs b/test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
index 5a0110f16d..6d317344f8 100644
--- a/test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
+++ b/test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
@@ -1,13 +1,8 @@
namespace Polly.Specs.Bulkhead;
[Collection(Constants.ParallelThreadDependentTestCollection)]
-public class BulkheadTResultAsyncSpecs : BulkheadSpecsBase
+public class BulkheadTResultAsyncSpecs(ITestOutputHelper testOutputHelper) : BulkheadSpecsBase(testOutputHelper)
{
- public BulkheadTResultAsyncSpecs(ITestOutputHelper testOutputHelper)
- : base(testOutputHelper)
- {
- }
-
#region Configuration
[Fact]
@@ -31,10 +26,10 @@ public void Should_throw_when_action_is_null()
var func = () => methodInfo.Invoke(instance, [action, new Context(), CancellationToken, false]);
- var exceptionAssertions = func.Should().Throw();
- exceptionAssertions.And.Message.Should().Be("Exception has been thrown by the target of an invocation.");
- exceptionAssertions.And.InnerException.Should().BeOfType()
- .Which.ParamName.Should().Be("action");
+ var exceptionAssertions = Should.Throw(func);
+ exceptionAssertions.Message.ShouldBe("Exception has been thrown by the target of an invocation.");
+ exceptionAssertions.InnerException.ShouldBeOfType()
+ .ParamName.ShouldBe("action");
}
[Fact]
@@ -43,8 +38,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero_and_no_ma
Action policy = () => Policy
.BulkheadAsync(0);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -53,8 +48,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero()
Action policy = () => Policy
.BulkheadAsync(0, 1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -63,8 +58,8 @@ public void Should_throw_when_maxQueuingActions_less_than_zero()
Action policy = () => Policy
.BulkheadAsync(1, -1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxQueuingActions");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxQueuingActions");
}
[Fact]
@@ -73,8 +68,8 @@ public void Should_throw_when_onBulkheadRejected_is_null()
Action policy = () => Policy
.BulkheadAsync(1, 0, null!);
- policy.Should().Throw().And
- .ParamName.Should().Be("onBulkheadRejectedAsync");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("onBulkheadRejectedAsync");
}
#endregion
@@ -105,7 +100,7 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
- await bulkhead.Awaiting(b => b.ExecuteAsync(_ => Task.FromResult(1), contextPassedToExecute)).Should().ThrowAsync();
+ await Should.ThrowAsync(() => bulkhead.ExecuteAsync(_ => Task.FromResult(1), contextPassedToExecute));
cancellationSource.Cancel();
@@ -116,9 +111,9 @@ public async Task Should_call_onBulkheadRejected_with_passed_context()
#endif
}
- contextPassedToOnRejected!.Should().NotBeNull();
- contextPassedToOnRejected!.OperationKey.Should().Be(operationKey);
- contextPassedToOnRejected!.Should().BeSameAs(contextPassedToExecute);
+ contextPassedToOnRejected.ShouldNotBeNull();
+ contextPassedToOnRejected.OperationKey.ShouldBe(operationKey);
+ contextPassedToOnRejected.ShouldBeSameAs(contextPassedToExecute);
}
#endregion
diff --git a/test/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs b/test/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs
index 1ec23064c7..94994fcdb6 100644
--- a/test/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs
+++ b/test/Polly.Specs/Bulkhead/BulkheadTResultSpecs.cs
@@ -1,13 +1,8 @@
namespace Polly.Specs.Bulkhead;
[Collection(Constants.ParallelThreadDependentTestCollection)]
-public class BulkheadTResultSpecs : BulkheadSpecsBase
+public class BulkheadTResultSpecs(ITestOutputHelper testOutputHelper) : BulkheadSpecsBase(testOutputHelper)
{
- public BulkheadTResultSpecs(ITestOutputHelper testOutputHelper)
- : base(testOutputHelper)
- {
- }
-
#region Configuration
[Fact]
@@ -31,10 +26,10 @@ public void Should_throw_when_action_is_null()
var func = () => methodInfo.Invoke(instance, [action, new Context(), CancellationToken]);
- var exceptionAssertions = func.Should().Throw();
- exceptionAssertions.And.Message.Should().Be("Exception has been thrown by the target of an invocation.");
- exceptionAssertions.And.InnerException.Should().BeOfType()
- .Which.ParamName.Should().Be("action");
+ var exceptionAssertions = Should.Throw(func);
+ exceptionAssertions.Message.ShouldBe("Exception has been thrown by the target of an invocation.");
+ exceptionAssertions.InnerException.ShouldBeOfType()
+ .ParamName.ShouldBe("action");
}
[Fact]
@@ -43,8 +38,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero_and_no_ma
Action policy = () => Policy
.Bulkhead(0);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -53,8 +48,8 @@ public void Should_throw_when_maxParallelization_less_or_equal_to_zero()
Action policy = () => Policy
.Bulkhead(0, 1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxParallelization");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxParallelization");
}
[Fact]
@@ -63,8 +58,8 @@ public void Should_throw_when_maxQueuingActions_less_than_zero()
Action policy = () => Policy
.Bulkhead(1, -1);
- policy.Should().Throw().And
- .ParamName.Should().Be("maxQueuingActions");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("maxQueuingActions");
}
[Fact]
@@ -73,8 +68,8 @@ public void Should_throw_when_onBulkheadRejected_is_null()
Action policy = () => Policy
.Bulkhead(1, 0, null!);
- policy.Should().Throw().And
- .ParamName.Should().Be("onBulkheadRejected");
+ Should.Throw(policy)
+ .ParamName.ShouldBe("onBulkheadRejected");
}
#endregion
@@ -105,7 +100,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));
- bulkhead.Invoking(b => b.Execute(_ => 1, contextPassedToExecute)).Should().Throw();
+ Should.Throw(() => bulkhead.Execute(_ => 1, contextPassedToExecute));
cancellationSource.Cancel();
@@ -116,9 +111,9 @@ public void Should_call_onBulkheadRejected_with_passed_context()
#endif
}
- contextPassedToOnRejected!.Should().NotBeNull();
- contextPassedToOnRejected!.OperationKey.Should().Be(operationKey);
- contextPassedToOnRejected!.Should().BeSameAs(contextPassedToExecute);
+ contextPassedToOnRejected!.ShouldNotBeNull();
+ contextPassedToOnRejected!.OperationKey.ShouldBe(operationKey);
+ contextPassedToOnRejected!.ShouldBeSameAs(contextPassedToExecute);
}
#endregion
diff --git a/test/Polly.Specs/Bulkhead/IBulkheadPolicySpecs.cs b/test/Polly.Specs/Bulkhead/IBulkheadPolicySpecs.cs
index 56f4c5fbba..8b31ef3a62 100644
--- a/test/Polly.Specs/Bulkhead/IBulkheadPolicySpecs.cs
+++ b/test/Polly.Specs/Bulkhead/IBulkheadPolicySpecs.cs
@@ -7,7 +7,7 @@ public void Should_be_able_to_use_BulkheadAvailableCount_via_interface()
{
IBulkheadPolicy bulkhead = Policy.Bulkhead(20, 10);
- bulkhead.BulkheadAvailableCount.Should().Be(20);
+ bulkhead.BulkheadAvailableCount.ShouldBe(20);
}
[Fact]
@@ -15,6 +15,6 @@ public void Should_be_able_to_use_QueueAvailableCount_via_interface()
{
IBulkheadPolicy bulkhead = Policy.Bulkhead(20, 10);
- bulkhead.QueueAvailableCount.Should().Be(10);
+ bulkhead.QueueAvailableCount.ShouldBe(10);
}
}
diff --git a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs
index 86679a7cb0..fc69ee2694 100644
--- a/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs
+++ b/test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs
@@ -8,7 +8,7 @@ public void Should_be_able_to_configure_for_near_future_time()
{
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.UtcNow.Date.AddDays(1));
- configure.Should().NotThrow();
+ Should.NotThrow(configure);
}
[Fact]
@@ -16,7 +16,7 @@ public void Should_be_able_to_configure_for_far_future()
{
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.MaxValue);
- configure.Should().NotThrow();
+ Should.NotThrow(configure);
}
[Fact]
@@ -24,7 +24,7 @@ public void Should_be_able_to_configure_for_past()
{
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.MinValue);
- configure.Should().NotThrow();
+ Should.NotThrow(configure);
}
[Fact]
@@ -32,7 +32,7 @@ public void Should_return_zero_ttl_if_configured_to_expire_in_past()
{
AbsoluteTtl ttlStrategy = new AbsoluteTtl(SystemClock.DateTimeOffsetUtcNow().Subtract(TimeSpan.FromTicks(1)));
- ttlStrategy.GetTtl(new Context("someOperationKey"), null).Timespan.Should().Be(TimeSpan.Zero);
+ ttlStrategy.GetTtl(new Context("someOperationKey"), null).Timespan.ShouldBe(TimeSpan.Zero);
}
[Fact]
@@ -44,7 +44,7 @@ public void Should_return_timespan_reflecting_time_until_expiry()
AbsoluteTtl ttlStrategy = new AbsoluteTtl(tomorrow);
SystemClock.DateTimeOffsetUtcNow = () => today;
- ttlStrategy.GetTtl(new Context("someOperationKey"), null).Timespan.Should().Be(TimeSpan.FromDays(1));
+ ttlStrategy.GetTtl(new Context("someOperationKey"), null).Timespan.ShouldBe(TimeSpan.FromDays(1));
}
public void Dispose() =>
diff --git a/test/Polly.Specs/Caching/AsyncSerializingCacheProviderSpecs.cs b/test/Polly.Specs/Caching/AsyncSerializingCacheProviderSpecs.cs
index 00d606f5cc..c809c59dbe 100644
--- a/test/Polly.Specs/Caching/AsyncSerializingCacheProviderSpecs.cs
+++ b/test/Polly.Specs/Caching/AsyncSerializingCacheProviderSpecs.cs
@@ -15,8 +15,8 @@ public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider
Action configure = () => _ = new AsyncSerializingCacheProvider(null!, stubObjectSerializer);
- configure.Should().Throw()
- .And.ParamName.Should().Be("wrappedCacheProvider");
+ Should.Throw(configure)
+ .ParamName.ShouldBe("wrappedCacheProvider");
}
[Fact]
@@ -24,8 +24,8 @@ public void Single_generic_constructor_should_throw_on_no_serializer()
{
Action configure = () => _ = new AsyncSerializingCacheProvider