text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>migration-policy-wrap-v8 // The "PolicyWrap" is integrated directly. The strategies are executed in the following order: // 1. Retry <== outer // 2. Timeout <== inner ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddRetry(new() { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>AddPipeline("my-app.my-api", builder => { builder.AddRetry(new() { ShouldHandle = new PredicateBuilder() .Handle<InvalidOperationException>() .Handle<HttpRequestException>() }); ...
fim
App-vNext/Polly
csharp
using System.Threading.RateLimiting; using Microsoft.Extensions.DependencyInjection; using Polly.RateLimiting; namespace Snippets.Docs; internal static class RateLimiter { public static void Usage() { #region rate-limiter // Add rate limiter with default options. // See https://www.p...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ice<ResiliencePipelineProvider<string>>(); // Retrieve your resilience pipeline using the name it was registered with ResiliencePipeline pipeline = pipelineProvider.GetPipeline("my-pipeline"); // Alternatively, you can use keyed services to retrieve the resilience pipeline ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Snippets.Docs; internal static class ResilienceContextUsage { #region resilience-keys public static class MyResilienceKeys { public static readonly ResiliencePropertyKey<string> Key1 = new("my-key-1"); public static readonly ResiliencePropertyKey<int> Key2 = new("...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.Net.Http; using System.Threading.RateLimiting; using Polly.RateLimiting; using Polly.Registry; using Polly.Retry; namespace Snippets.Docs; internal static class ResiliencePipelineRegistry { public static async Task Usage() { #region registry-usage var registry = ne...
fim
App-vNext/Polly
csharp
<|fim_suffix|>OutcomeAsync( static async (context, state) => { Console.WriteLine("State: {0}", state); try { await MyMethodAsync(context.CancellationToken); // Use static utility methods from Outcome to eas...
fim
App-vNext/Polly
csharp
<|fim_suffix|>wait ShouldRetryAsync(args.Outcome.Result!, args.Context.CancellationToken); } }; #endregion } private static Task<bool> ShouldRetryAsync(HttpResponseMessage response, CancellationToken cancellationToken) => Task.FromResult(true); public static void ShouldHandleP...
fim
App-vNext/Polly
csharp
<|fim_suffix|>CancellationTokenSource>("cts"); var retry = new ResiliencePipelineBuilder() .AddRetry(new() { OnRetry = async args => { if (args.Outcome.Exception is TimeoutException) { if (arg...
fim
App-vNext/Polly
csharp
<|fim_suffix|>er : MeteringEnricher { public override void Enrich<TResult, TArgs>(in EnrichmentContext<TResult, TArgs> context) { context.Tags.Add(new("my-custom-tag", "custom-value")); } } #endregion public static void MeteringEnricherRegistration() { #...
fim
App-vNext/Polly
csharp
<|fim_suffix|>he pipeline's composition with the descriptor. Assert.Equal(2, descriptor.Strategies.Count); // Verify the retry settings. var retryOptions = Assert.IsType<RetryStrategyOptions>(descriptor.Strategies[0].Options); Assert.Equal(4, retryOptions.MaxRetryAttempts); // ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.Net.Http; using Polly.Timeout; namespace Snippets.Docs; internal static class Timeout { public static async Task Usage() { #region timeout // To add a timeout with a custom TimeSpan duration new ResiliencePipelineBuilder().AddTimeout(TimeSpan.FromSeconds(3)...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Snippets.Docs.Utils; internal sealed class SomeExceptionType : Exception { publ<|fim_suffix|>ublic SomeExceptionType(string message, Exception innerException) : base(message, innerException) { } public SomeExceptionType() { } } <|fim_middle|>ic SomeExceptionTyp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>C<|fim_suffix|>riteLine("Hello Polly!"); <|fim_middle|>onsole.W<|endoftext|>
fim
App-vNext/Polly
csharp
<|fim_suffix|>context, 99); args.FailureRate.ShouldBe(expectedFailureRate); args.FailureCount.ShouldBe(failureCount); args.Context.ShouldBe(context); args.HalfOpenAttempts.ShouldBe(99); } } <|fim_prefix|>using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker; publi...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.CircuitBreaker; namespace P<|fim_suffix|>RetryAfter.ShouldBeNull(); } [Fact] public void Ctor_Message_RetryAfter_InnerException_Ok() { var exception = new BrokenCircuitException(TestMessage, TestRetryAfter, new InvalidOperationException()); exception.Message.S...
fim
App-vNext/Polly
csharp
<|fim_suffix|>lationToken); called.ShouldBe(2); } [Fact] public async Task Initialize_Ok() { var cancellationToken = TestCancellation.Token; var control = new CircuitBreakerManualControl(); var isolateCalled = false; var resetCalled = false; control.Ini...
fim
App-vNext/Polly
csharp
<|fim_suffix|>must be between 00:00:00.5000000 and 1.00:00:00. The field BreakDuration must be between 00:00:00.5000000 and 1.00:00:00. The ShouldHandle field is required. """, StringCompareShould.IgnoreLineEndings); } } <|fim_prefix|>using System.ComponentModel.DataA...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker; public static class C<|fim_suffix|>.Outcome.Result.ShouldBe(1); } } <|fim_middle|>ircuitBreakerPredicateArgumentsTests { [Fact] public static void Ctor_Ok() { var args = new CircuitBreakerPredicateArguments<in...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ShouldBe(0); exception = Assert.Throws<BrokenCircuitException>(() => strategy.Execute(_ => 0, cancellationToken)); exception.RetryAfter.ShouldBe(halfBreakDuration); // Circuit Half Opened timeProvider.Advance(halfBreakDuration); strategy.Execute(_ => -1, cancellati...
fim
App-vNext/Polly
csharp
<|fim_suffix|>rResilienceStrategy<int>(_options.ShouldHandle!, _controller, _options.StateProvider, _options.ManualControl).AsPipeline(); #pragma warning restore CA2000 // Dispose objects before losing scope } <|fim_prefix|>using Microsoft.Extensions.Time.Testing; using NSubstitute; using Polly.CircuitBreaker; using Po...
fim
App-vNext/Polly
csharp
<|fim_suffix|> Should.Throw<InvalidOperationException>(() => provider.Initialize(() => CircuitState.Closed)); } [Fact] public void Initialize_Ok() { var provider = new CircuitBreakerStateProvider(); var stateCalled = false; provider.Initialize( () => ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Failure) { _metrics.Received(1).IncrementFailure(); } else { _metrics.DidNotReceive().IncrementFailure(); } } [Fact] public void OnCircuitClosed_Ok() { _metrics = Substitute.For<HealthMetrics>(TimeProvider.System); ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Microsoft.Extensions.Time.Testing; using NSubstitute; using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker.Controller; public class CircuitStateControllerTests { private readonly FakeTimeProvider _timeProvider = new(); private readonly CircuitBreakerStrategyOptions<int> _...
fim
App-vNext/Polly
csharp
<|fim_suffix|>cessing() { var scheduler = new ScheduledTaskExecutor(); var otherTask = scheduler.ScheduleTask(() => Task.CompletedTask); await otherTask; scheduler.Dispose(); #pragma warning disable S3966 // Objects should not be disposed more than once scheduler.Dispose(); #...
fim
App-vNext/Polly
csharp
using Polly.CircuitBreaker.Health; namespace Polly.Core.Tests.CircuitBreaker.Health; public class HealthMetricsTests { [InlineData(100, typeof(SingleHealthMetrics))] [InlineData(199, typeof(SingleHealthMetrics))] [InlineData(200, typeof(RollingHealthMetrics))] [InlineData(201, typeof(RollingHealthMetr...
fim
App-vNext/Polly
csharp
<|fim_suffix|> = Create(); metrics.IncrementSuccess(); metrics.Reset(); metrics.GetHealthInfo().Throughput.ShouldBe(0); } [InlineData(true)] [InlineData(false)] [Theory] public void GetHealthInfo_SamplingDurationRespected(bool variance) { var metrics = Create()...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Microsoft.Extensions.Time.Testing; using Polly.CircuitBreaker.Health; namespace Polly.Core.Tests.CircuitBreaker.Health; public class SingleHealthMetricsTests { private readonly FakeTimeProvider _timeProvider; public SingleHealthMetricsTests() => _timeProvider = new FakeTimeProvider(); ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>uldBeOfType<InvalidOperationException>(); exception.RetryAfter.ShouldBeNull(); } #if NETFRAMEWORK [Fact] public void BinarySerialization_Ok() { var exception = new IsolatedCircuitException(TestMessage, new InvalidOperationException()); IsolatedCircuitException roun...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker; <|fim_suffix|> var args = new OnCircuitClosedArguments<int>(context, Outcome.FromResult(1), true); // Assert args.Context.ShouldBe(context); args.Outcome.Result.ShouldBe(1); args.IsManual.ShouldBeTrue(...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker; public static class OnCircuitHalfOpenedArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(TestCancellation.Token); // Act <|fim_s...
fim
App-vNext/Polly
csharp
using Polly.CircuitBreaker; namespace Polly.Core.Tests.CircuitBreaker; public static class OnCircuitOpenedArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(TestCancellation.Token); // Act var args = new OnCircu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests;<|fim_suffix|>ass ExecutionRejectedExceptionTests { [Fact] public void Ctor_Ok() { new CustomException().Message.ShouldBe("Exception of type 'Polly.Core.Tests.ExecutionRejectedExceptionTests+CustomException' was thrown."); new CustomException("Dummy")...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Fallback; namespace Polly.Core.Tests.Fallback; public class FallbackHandlerTests { [Fact] public async Task GenerateAction_Generic_Ok() { v<|fim_suffix|>, Outcome.FromResult("primary")))!; outcome.Result.ShouldBe("secondary"); } } <|fim_middle|>ar handler = Fa...
fim
App-vNext/Polly
csharp
<|fim_suffix|>uldHandle, Func<Outcome<T>> fallback) => new( args => new ValueTask<bool>(shouldHandle(args.Outcome)), _ => new ValueTask<Outcome<T>>(fallback())); } <|fim_prefix|>using Polly.Fallback; namespace <|fim_middle|>Polly.Core.Tests.Fallback; internal static class Fall...
fim
App-vNext/Polly
csharp
<|fim_suffix|>heoryData<Action<ResiliencePipelineBuilder<int>>> FallbackOverloadsGeneric = new() { builder => { builder.AddFallback(new FallbackStrategyOptions<int> { FallbackAction = _ => Outcome.FromResultAsValueTask(0), ShouldHandle = _ => P...
fim
App-vNext/Polly
csharp
<|fim_suffix|>e(); fallbackActionCalled.ShouldBeFalse(); } private void SetHandler( Func<Outcome<string>, bool> shouldHandle, Func<Outcome<string>> fallback) => _handler = FallbackHelper.CreateHandler(shouldHandle, fallback); private ResiliencePipeline<string> Create() ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>on = Should.Throw<ValidationException>(() => ValidationHelper.ValidateObject(new(options, "Invalid."))); exception.Message.Trim().ShouldBe(""" Invalid. Validation Errors: The ShouldHandle field is required. The FallbackAction field is required. ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>tance .ShouldBeSameAs(strategy); } } <|fim_prefix|>using Microsoft.Extensions.Time.Testing; using NSubstitute; using Polly.Testing; using Polly.Utils.Pipeline; namespace Polly.Core.Tests; public class GenericResiliencePipelineBuilderTests { private readonly ResiliencePipelineBuilder<...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging.Utils; namespace Polly.Core.Tests.Hedging.Controller; public class HedgingControllerTests { [Fact] public async Task Pooling_Ok() { var context = ResilienceContextPool.Shared.Get(TestCancellation.Token); var telemetry = TestUtilities.CreateResilienceTeleme...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.Globalization; using Polly.Hedging; using Polly.Hedging.Controller; using Polly.Hedging.Utils; using Polly.Telemetry; using Polly.Utils; namespace Polly.Core.Tests.Hedging.Controller; public class HedgingExecutionContextTests : IDisposable { private const string Handled = "Handled"; ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; using Polly.Hedging.Controller; using Polly.Hedging.Utils; using Polly.Telemetry; using Polly.Utils; namespace Polly.Core.Tests.Hedging.Controller; public class TaskExecutionTests : IDisposable { private const string Handled = "Handled"; private readonly ResiliencePropertyKe...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; namespace Polly.Core.Tests.Hedging; public static class HedgingActionGeneratorArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var cancellationToken = TestCancellation.Token; var primaryContext = ResilienceContextPool.Shared.Get(c...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; namespace Polly.Core.Tests.Hedging; internal class HedgingActions { private readonly TimeProvider _timeProvider; public HedgingActions(TimeProvider timeProvider) { _timeProvider = timeProvider; Functions = [ GetApples, Ge...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; namespace Polly.Core.Tests.Hedging; public <|fim_suffix|>orArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(TestCancellation.Token); // Act var args = new HedgingDelayGenerat...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Outcome!))!, generator, onHedging); } <|fim_prefix|>using <|fim_middle|>Polly.Hedging; using Polly.Hedging.Utils; namespace Polly.Core.Tests.Hedging; internal static class HedgingHelper { public static HedgingHandler<T> CreateHandler<T>( Func<Outcome<T>, bool> shouldHandle, Func<Hed...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; namespace Polly.Core.Tests.Hedging; public static class HedgingPredicateArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(T<|fim_suffix|> { // Arrange var context = Resilienc...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Polly.Hedging; using Polly.Testing; namespace Polly.Core.Tests.Hedging; public class HedgingResiliencePipelineBuilderExtensionsTests { private readonly ResiliencePipelineBuilder<string> _builder = new(); [Fact] public void AddHedging_Generi...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.Threading.Tasks; using Polly.Hedging; using Polly.Hedging.Utils; using Polly.Telemetry; using Polly.Testing; using Xunit.Abstractions; namespace Polly.Core.Tests.Hedging; public class HedgingResilienceStrategyTests : IDisposable { private const string Success = "Success"; private c...
fim
App-vNext/Polly
csharp
<|fim_suffix|>nds(20), TestCancellation.Token) .ShouldBeTrue("The test thread failed to complete within the timeout"); (await task).Result.ShouldBe(99); } [Fact] public async Task ShouldHandle_EnsureDefaults() { var options = new HedgingStrategyOptions<int>(); var co...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System; namespace Polly.Core.Tests.Hedging; internal class HedgingTimeProvider : TimeProvider { private DateTimeOffset _utcNow; public HedgingTimeProvider() => _utcNow = DateTimeOffset.UtcNow; public TimeSpan AutoAdvance { get; set; } public void Advance(TimeSpan diff) { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Context, 1); // Assert args.PrimaryContext.ShouldBe(primaryContext); args.ActionContext.ShouldBe(actionContext); args.AttemptNumber.ShouldBe(1); } } <|fim_prefix|>using Polly.Hedging; namespace Polly.Core.Tests.Hedging; public static class OnHedgingArgumentsTests { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>1), token); #endif return SlowTaskResult; } } <|fim_prefix|>namespace Polly.Core.Tests.Hedging; internal class PrimaryStringTasks { public const string InstantTaskResult = "Instant"; public const string FastTaskResult = "I am fast!"; public const string SlowTaskResult = "I am s...
fim
App-vNext/Polly
csharp
<|fim_suffix|> IsDisposed = true; OnDisposed.TrySetResult(true); } public override string ToString() => Name; } <|fim_prefix|>namespace Polly.Core.Tests.Helpers; internal class DisposableResult : IDisposable { public readonly TaskCompletionSource<bool> OnDisposed = new(); public DisposableR...
fim
App-vNext/Polly
csharp
namespace Polly.Core.Tests.Issues; public partial class IssuesTests { [Fact] public async Task OnRetry_Contains_User_Context_2597() { // Arrange var propertyKey = Guid.NewGuid().ToString(); var propertyValue = Guid.NewGuid().ToString(); var key = new ResiliencePropertyKey<s...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Hedging; using Polly.Timeout; namespace Polly.Core.Tests.Issues; public partial class IssuesTests { // https://github.com/App-vNext/Polly/issues/3086 // When a strategy substitutes the caller's CancellationToken with an internal one (timeout, hedging), // a caller-initiated cance...
fim
App-vNext/Polly
csharp
<|fim_suffix|> _ = registry.GetOrAddPipeline("A", builder => { var stateProvider = new CircuitBreakerStateProvider(); builder.AddCircuitBreaker(new() { StateProvider = stateProvider }); states.Add(stateProvider); }); _ = registry.GetOrAddPipeline("B", buil...
fim
App-vNext/Polly
csharp
using Polly.CircuitBreaker; namespace Polly.Core.Tests.Issues; public partial class IssuesTests { [Fact] public void CircuitBreakerStateSharing_959() { var cancellationToken = TestCancellation.Token; var options = new CircuitBreakerStrategyOptions { FailureRatio = 1, ...
fim
App-vNext/Polly
csharp
<|fim_suffix|> contextChecked = true; return PredicateResult.False(); } }) .Build(); // execute the retry strategy.Execute(_ => 0, TestCancellation.Token); contextChecked.ShouldBeTrue(); } } <|fim_prefix|>using Polly.R...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Retry; namespace Polly.Core.Tests.Issues; public partial class IssuesTests { [Fact] public void HandleMultipleResults_898() { var cancellationToken = TestCancellation.Token; var isRetryKey = new ResiliencePropertyKey<bool>("is-retry"); var options = new Re...
fim
App-vNext/Polly
csharp
<|fim_suffix|>eSpan.FromSeconds(2), MaxDelay = TimeSpan.FromSeconds(30), MaxRetryAttempts = int.MaxValue, UseJitter = true, OnRetry = (args) => { args.RetryDelay.ShouldBeGreaterThan(TimeSpan.Zero, $"RetryDelay is less than zero after {args.Atte...
fim
App-vNext/Polly
csharp
<|fim_suffix|>r(); } <|fim_prefix|>using Microsoft.Extensions.Time.Testi<|fim_middle|>ng; namespace Polly.Core.Tests.Issues; public partial class IssuesTests { private FakeTimeProvider TimeProvider { get; } = new FakeTimeProvide<|endoftext|>
fim
App-vNext/Polly
csharp
<|fim_suffix|> { var outcome = Outcome.FromException<string>(new InvalidOperationException()); Should.Throw<InvalidOperationException>(outcome.ThrowIfException); } [Fact] public void FromException_Throws_If_Null() => Assert.Throws<ArgumentNullException>("exception", () => Outcome...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.CircuitBreaker; using Polly.Fallback; using Polly.Hedging; using Polly.Retry; namespace Polly.Core.Tests; public class PredicateBuilderTests { public static TheoryData<Action<PredicateBuilder<string>>, Outcome<string>, bool> HandleResultData = new() { { builder => builder.Han...
fim
App-vNext/Polly
csharp
<|fim_suffix|>e()).ShouldBeFalse(); } <|fim_prefix|>namespace Polly.Core.Tests; public class PredicateResultTests { [Fact] public async Task True_Ok() => (await PredicateResult.True()).ShouldBeTrue(); [Fact] public async Task False_Ok() => (await Predica<|fim_middle|>teResult.Fals<|end...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Registry; namespace Polly.Core.Tests.Registry; public static class ConfigureBuilderContextTests { [Fact] public static void AddReloadToken_Ok() { var context = new ConfigureBuilderContext<int>(0, "dummy", "dummy"); using var source = new CancellationTokenSource()...
fim
App-vNext/Polly
csharp
<|fim_suffix|>) { var provider = new Provider { GenericStrategy = ResiliencePipeline<string>.Empty }; provider.GetPipeline<string>("exists").ShouldBe(provider.GenericStrategy); } private class Provider : ResiliencePipelineProvider<string> { public ResiliencePipeline? Strategy {...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Registry; namespace Polly.Core.Tests.Registry; public class ResiliencePipelineRegistryOptionsTests { [Fact] public void Ctor_EnsureDefaults() { ResiliencePipelineRegistryOptions<object> options = new(); o<|fim_suffix|>ldNotBeNull(); options.BuilderNameFor...
fim
App-vNext/Polly
csharp
<|fim_suffix|>omSeconds(1)); }); #pragma warning disable S3966 // Objects should not be disposed more than once if (isAsync) { await registry.DisposeAsync(); await registry.DisposeAsync(); } else { registry.Dispose(); registry.Disp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests.Registry; public record StrategyId(Type Type, string BuilderName, string InstanceName = "") { public static readonly ResiliencePropertyKey<S<|fim_suffix|>ualityComparer<StrategyId>.Default; public static readonly IEqualityComparer<StrategyId> BuilderComparer = new Buil...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests; public class ResilienceContextPoolTests { [Fact] public void Shared_NotNull() => ResilienceContextPool.Shared.ShouldNotBeNull(); [Fact] public void Shared_SameInstance() => ResilienceContextPool.Shared.ShouldBeSameAs(ResilienceContextPool.Share...
fim
App-vNext/Polly
csharp
<|fim_suffix|> context.IsInitialized.ShouldBeTrue(); context.IsSynchronous.ShouldBe(synchronous); context.ContinueOnCapturedContext.ShouldBeFalse(); } } <|fim_prefix|>namespace Polly.Core.Tests; public class ResilienceContextTests { [Theory] [InlineData(true)] [InlineData(false)] pu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Time.Testing; using NSubstitute; using Polly.Retry; using Polly.Telemetry; using Polly.Testing; using Polly.Utils.Pipeline; namespace Polly.Core.Tests; public class ResiliencePipelineBuilderTests { [Fact] public void Ctor_En...
fim
App-vNext/Polly
csharp
using Polly.Utils; using Polly.Utils.Pipeline; namespace Polly.Core.Tests; public partial class ResiliencePipelineTests { #pragma warning disable IDE0028 public static TheoryData<Func<ResiliencePipeline<string>, ValueTask>> ExecuteAsyncGenericStrategyData = new() { async strategy => { ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Utils; using Polly.Utils.Pipeline; namespace Polly.Core.Tests; public partial class ResiliencePipelineTests { #pragma warning disable IDE0028 public static TheoryData<Action<ResiliencePipeline<string>>> ExecuteGenericStrategyData = new() { strategy => { st...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests; #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public partial class ResiliencePipelineTests { public static IEnum<|fim_suffix|> AssertContext = AssertResilienceContextAndToken, }; yield return new...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ceStrategy { Before = (c, _) => { context = c; parameters.AssertContext(c); }, }; var result = await parameters.Execute(strategy.AsPipeline()); parameters.AssertContextAfter(context!); parameters....
fim
App-vNext/Polly
csharp
<|fim_suffix|>d(), context)); AssertStackTrace(s => s.Execute((_, _) => MyThrowingMethod(), context)); AssertStackTrace(s => s.Execute((_, _) => MyThrowingMethod(), context, "state")); AssertStackTrace(s => s.Execute((_, _) => MyThrowingMethod(), "state")); AssertStackTrace(s => s.Execut...
fim
App-vNext/Polly
csharp
<|fim_suffix|>of(long)); context.ContinueOnCapturedContext.ShouldBeFalse(); } static void AssertResilienceContextAndToken(ResilienceContext context) { AssertResilienceContext(context); context.CancellationToken.ShouldBe(CancellationToken); } ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using NSubstitute; using Polly.Utils; using Polly.Utils.Pipeline; namespace Polly.Core.Tests; public partial class ResiliencePipelineTests { public static readonly CancellationToken CancellationToken = new CancellationTokenSource().Token; #pragma warning disable IDE0028 public static TheoryData...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests; public class ResiliencePropertiesTests { [Fact] public void TryGetValue_Ok() { var key = new ResiliencePropertyKey<long>("dummy"); var props = new ResilienceProperties(); props.Set(key, 12345); props.TryGetValue(key, out var val).S...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Core.Tests; public class ResiliencePropertyKeyTests { [Fact] public void Ctor_Ok() { var instance = new ResiliencePropertyKey<int>("dummy")<|fim_suffix|>blic void Ctor_Null_Throws() => Assert.Throws<ArgumentNullException>(() => new ResiliencePropertyKey<int>(nu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>na<|fim_suffix|>nsTests { [Fact] public void Ctor_EnsureDefaults() { var options = new TestResilienceStrategyOptions(); options.Name.ShouldBeNull(); } } <|fim_middle|>mespace Polly.Core.Tests; public class ResilienceStrategyOptio<|endoftext|>
fim
App-vNext/Polly
csharp
<|fim_suffix|>Span.FromSeconds(3)); args.Duration.ShouldBe(TimeSpan.MaxValue); } } <|fim_prefix|>using Polly.Retry; namespace Polly.Core.Tests.Retry; public static class OnRetryArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var c<|fim_middle|>ontext = Resilie...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Retry; namespace Polly.Core.Tests.Retry; public class RetryConstantsTests { [Fact] public void EnsureDefaults() { RetryConstant<|fim_suffix|>nds(2)); RetryConstants.DefaultRetryCount.ShouldBe(3); RetryConstants.MaxRetryCount.ShouldBe(int.MaxValue); ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>houldBe(2); } } <|fim_prefix|>usin<|fim_middle|>g Polly.Retry; namespace Polly.Core.Tests.Retry; public static class RetryDelayGeneratorArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(TestCancellation.Token)...
fim
App-vNext/Polly
csharp
<|fim_suffix|>nstant, false, 0, TimeSpan.Zero, null, ref state, _randomizer).ShouldBe(TimeSpan.Zero); RetryHelper.GetRetryDelay(DelayBackoffType.Constant, false, 1, TimeSpan.Zero, null, ref state, _randomizer).ShouldBe(TimeSpan.Zero); RetryHelper.GetRetryDelay(DelayBackoffType.Constant, false, 2, TimeSp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using NSubstitute; using Polly.Retry; using Polly.Testing; namespace Polly.Core.Tests.Retry; public class RetryResiliencePipelineBuilderExtensionsTests { #pragma warning disable IDE0028 public static readonly TheoryData<Action<ResiliencePipelineBuilder>> ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Microsoft.Extensions.Time.Testing; using Polly.Retry; using Polly.Telemetry; using Polly.Testing; namespace Polly.Core.Tests.Retry; public class RetryResilienceStrategyTests { private readonly RetryStrategyOptions _options = new(); private readonly FakeTimeProvider _timeProvider = new(); ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Polly.Retry; using Polly.Utils; namespace Polly.Core.Tests.Retry; public class RetryStrategyOptionsTests { [Fact] public void Ctor_Ok() { var options = new RetryStrategyOptions<int>(); options.ShouldHandle.ShouldNotBeNull();...
fim
App-vNext/Polly
csharp
using Polly.Retry; namespace Polly.Core.Tests.Retry; public static class ShouldRetryArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Shared.Get(TestCancellation.Token); // Act var args = new RetryPredicateArguments<int>(...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Simmy.Beh<|fim_suffix|>ntext.ShouldBe(context); } } <|fim_middle|>avior; namespace Polly.Core.Tests.Simmy.Behavior; public static class BehaviorGeneratorArgumentsTests { [Fact] public static void Ctor_Ok() { // Arrange var context = ResilienceContextPool.Share...
fim
App-vNext/Polly
csharp
<|fim_suffix|>DefaultName.ShouldBe("Chaos.Behavior"); ChaosBehaviorConstants.OnBehaviorInjectedEvent.ShouldBe("Chaos.OnBehavior"); } } <|fim_prefix|>using Polly.Simmy.Behavior; namespace Polly.Core.Tests.Simmy.Behavior; public class ChaosBehaviorConstantsTests { [Fact] public void EnsureDefaults()...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Polly.Simmy; using Polly.Simmy.Behavior; using Polly.Testing; namespace Polly.Core.Tests.Simmy.Behavior; public class ChaosBehaviorPipelineBuilderExtensionsTests { public static IEnumerable<object[]> AddBehavior_Ok_Data() { var context =...
fim
App-vNext/Polly
csharp
<|fim_suffix|>onRateGenerator.ShouldBeNull(); sut.BehaviorGenerator.ShouldBeNull(); sut.OnBehaviorInjected.ShouldBeNull(); } [Fact] public void InvalidOptions() { var sut = new ChaosBehaviorStrategyOptions(); var exception = Should.Throw<ValidationException>(() => Valid...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using Polly.Simmy.Behavior; using Polly.Telemetry; namespace Polly.Core.Tests.Simmy.Behavior; public class ChaosBehaviorStrategyTests { private readonly ResilienceStrategyTelemetry _telemetry; private readonly ChaosBehaviorStrategyOptions _options; private readonly List<TelemetryEventArgume...
fim
App-vNext/Polly
csharp
<|fim_suffix|>rInjectedArguments(context); // Assert args.Context.ShouldBe(context); } } <|fim_prefix|>using Polly.Simmy.Behavior; namespace Polly.Core.Tests.Simmy.Behavior; public stati<|fim_middle|>c class OnBehaviorInjectedArgumentsTests { [Fact] public static void Ctor_Ok() { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>eTrue(); } } <|fim_prefix|>using Polly.Simmy; namespace Polly.Core.Tests; public class ChaosStrategyConstantsTests { [Fact] public void EnsureDefaults() { ChaosStrategyConstants.MinInjectionThreshold.ShouldBe(0d); ChaosStrategyCo<|fim_middle|>nstants.MaxInjectionThreshold...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Polly.Simmy; using Polly.Utils; namespace Polly.Core.Tests.Simmy; public class ChaosStrategyOptionsTTests { [Fact] public void Ctor_Ok() { var sut = new TestChaosStrategyOptions<int>(); sut.Randomizer.ShouldNotBeNull(); ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel.DataAnnotations; using Polly.Simmy; using Polly.Utils; namespace Polly.Core.Tests.Simmy; public class ChaosStrategyOptionsTests { [Fact] public void Ctor_Ok() { var sut = new TestChaosStrategyOptions(); sut.Randomizer.ShouldNotBe<|fim_suffix|>"""...
fim
App-vNext/Polly
csharp