using Polly; using Polly.Retry; namespace Elsa.Resilience.Core.UnitTests.TestHelpers; /// /// A strategy that configures a real Polly retry pipeline with zero delay, so tests can exercise actual retry behavior. /// internal class TestRetryStrategy : IResilienceStrategy { public string Id { get; set; } = "test-retry"; public string DisplayName { get; set; } = "Test Retry"; public int MaxRetryAttempts { get; set; } = 2; public Task ConfigurePipeline(ResiliencePipelineBuilder pipelineBuilder, ResilienceContext context) { pipelineBuilder.AddRetry(new RetryStrategyOptions { MaxRetryAttempts = MaxRetryAttempts, Delay = TimeSpan.Zero, BackoffType = DelayBackoffType.Constant, ShouldHandle = new PredicateBuilder().Handle() }); return Task.CompletedTask; } } /// /// A strategy that adds nothing to the pipeline, used to verify pass-through behavior and polymorphic serialization. /// internal class TestNoopStrategy : IResilienceStrategy { public string Id { get; set; } = "test-noop"; public string DisplayName { get; set; } = "Test Noop"; public TestStrategyFlavor Flavor { get; set; } public Task ConfigurePipeline(ResiliencePipelineBuilder pipelineBuilder, ResilienceContext context) => Task.CompletedTask; } internal enum TestStrategyFlavor { Plain, Fancy }