Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Polly.Testing package #1394

Merged
merged 10 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 src/Polly.Testing/InnerStrategiesDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Polly.Testing;

/// <summary>
/// Describes the pipeline of resilience strategy.
/// Describes the pipeline of a resilience strategy.
/// </summary>
/// <param name="Strategies">The strategies the pipeline is composed of.</param>
/// <param name="HasTelemetry">Gets a value indicating whether the pipeline has telemetry enabled.</param>
Expand Down
25 changes: 25 additions & 0 deletions src/Polly.Testing/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# About Polly.Testing

This package exposes API and utilities that can be used to assert the composition of resilience strategies.
martincostello marked this conversation as resolved.
Show resolved Hide resolved

``` csharp
// Build your resilience strategy.
ResilienceStrategy strategy = new ResilienceStrategyBuilder()
.AddRetry(new RetryStrategyOptions
{
RetryCount = 4
})
.AddTimeout(TimeSpan.FromSeconds(1))
.ConfigureTelemetry(NullLoggerFactory.Instance)
.Build();

// Retrieve inner strategies.
InnerStrategiesDescriptor descriptor = strategy.GetInnerStrategies();

// Assert the composition.
Assert.True(descriptor.HasTelemetry);
Assert.Equal(2, descriptor.Strategies.Count);

var retryOptions = Assert.IsType<RetryStrategyOptions>(descriptor.Strategies[0]);
Assert.Equal(4, retryOptions.RetryCount);

var timeoutOptions = Assert.IsType<TimeoutStrategyOptions>(descriptor.Strategies[0]);
Assert.Equal(TimeSpan.FromSeconds(1), timeoutOptions.Timeout);
```