text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>oken).AsTask());
_wasChaosUnleashed.ShouldBeFalse();
_enableGeneratorExecuted.ShouldBeTrue();
_injectionRateGeneratorExecuted.ShouldBeFalse();
}
[Fact]
public async Task Should_not_inject_chaos_when_it_was_cancelled_on_injection_rate_generator()
{
using va... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> await Should.ThrowAsync<OperationCanceledException>(() => sut.AsPipeline().ExecuteAsync(async _ => await Task.CompletedTask, cts.Token).AsTask());
_wasChaosUnleashed.ShouldBeFalse();
_enableGeneratorExecuted.ShouldBeFalse();
_injectionRateGeneratorExecuted.ShouldBeFalse();
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> // Arrange
var context = ResilienceContextPool.Shared.Get(TestCancellation.Token);
// Act
var args = new EnabledGeneratorArguments(context);
// Assert
args.Context.ShouldBe(context);
}
}
<|fim_prefix|>usin<|fim_middle|>g Polly.Simmy;
namespace Polly.Core.... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>lt");
ChaosFaultConstants.OnFaultInjectedEvent.ShouldBe("Chaos.OnFault");
}
}
<|fim_prefix|>using Polly.Simmy.Fault;
namespace P<|fim_middle|>olly.Core.Tests.Simmy.Fault;
public class ChaosFaultConstantsTests
{
[Fact]
public void EnsureDefaults()
{
ChaosFaultConstants.Def... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.ComponentModel.DataAnnotations;
using Polly.Simmy;
using Polly.Simmy.Fault;
using Polly.Testing;
namespace Polly.Core.Tests.Simmy.Fault;
public class ChaosFaultPipelineBuilderExtensionsTests
{
#pragma warning disable IDE0028
public static readonly TheoryData<Action<ResiliencePipelineBui... | fim | App-vNext/Polly | csharp |
using System.ComponentModel.DataAnnotations;
using Polly.Simmy;
using Polly.Simmy.Fault;
using Polly.Utils;
namespace Polly.Core.Tests.Simmy.Fault;
public class ChaosFaultStrategyOptionsTests
{
[Fact]
public void Ctor_Ok()
{
var sut = new ChaosFaultStrategyOptions();
sut.Randomizer.Should... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy;
using Polly.Simmy.Fault;
using Polly.Telemetry;
namespace Polly.Core.Tests.Simmy.Fault;
public class ChaosFaultStrategyTests
{
private readonly ResilienceStrategyTelemetry _telemetry;
private readonly List<TelemetryEventArguments<object, object>> _args = [];
private bool ... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy.Fault;
namespace Polly.Core.Tests.Simmy.Fault;
public static class FaultGeneratorArgument<|fim_suffix|>eContextPool.Shared.Get(TestCancellation.Token);
// Act
var args = new FaultGeneratorArguments(context);
// Assert
args.Context.ShouldBe(context);
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy.Fault;
namespace Polly.Core.Tests.Simmy.Fault;
public class FaultGeneratorTests
{
[Fact]
public void AddException_Generic_Ok()
{
var generator = new FaultGenerator();
generator.AddException<InvalidOperationException>();
Generate(generator).ShouldB... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> var args = new OnFaultInjectedArguments(context, fault);
// Assert
args.Context.ShouldBe(context);
args.Fault.ShouldBe(fault);
}
}
<|fim_prefix|>using Polly.Simmy.Fault;
namespace Polly.Core.Tests.Simmy.Fault;
public static class OnFaultInjectedArgumentsTests
{
[Fa... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>context);
}
}
<|fim_prefix|>using Polly.Simmy;
namespace Polly.Core.Tests.Simmy.Outcomes;
public static class InjectionRateGeneratorArg<|fim_middle|>umentsTests
{
[Fact]
public static void Ctor_Ok()
{
// Arrange
var context = ResilienceContextPool.Shared.Get(TestCancellat... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>Constants.OnLatencyInjectedEvent.ShouldBe("Chaos.OnLatency");
ChaosLatencyConstants.DefaultLatency.ShouldBe(TimeSpan.FromSeconds(30));
}
}
<|fim_prefix|>using Polly.Simmy.Latency;
namespace Polly.Core.Tests.Simmy.Latency;
public class ChaosLatencyCon<|fim_middle|>stantsTests
{
[Fact]
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy;
using Polly.Simmy.Latency;
using Polly.Testing;
namespace Polly.Core.Tests.Simmy.Latency;
public class ChaosLatencyPipelineBuilderExtensionsTests
{
public static IEnumerable<object[]> AddLatency_Ok_Data()
{
var context = ResilienceContextPool.Shared.Get(TestCancellatio... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ll();
sut.Enabled.ShouldBeTrue();
sut.EnabledGenerator.ShouldBeNull();
sut.InjectionRate.ShouldBe(ChaosStrategyConstants.DefaultInjectionRate);
sut.InjectionRateGenerator.ShouldBeNull();
sut.Latency.ShouldBe(ChaosLatencyConstants.DefaultLatency);
sut.Latency... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Microsoft.Extensions.Time.Testing;
using Polly.Simmy.Latency;
using Polly.Telemetry;
namespace Polly.Core.Tests.Simmy.Latency;
public class ChaosLatencyStrategyTests : IDisposable
{
private readonly ResilienceStrategyTelemetry _telemetry;
private readonly FakeTimeProvider _timeProvider = ... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ncyGeneratorArguments(context);
// Assert
args.Context.ShouldNotBeNull();
}
}
<|fim_prefix|>using Polly.Simmy.Latency;
namespace Polly.Core.Tests.Simmy.Latency;
public static class LatencyGeneratorArgumentsTests
{
[Fact]
public static void Ctor_Ok()<|fim_middle|>
{
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy.Latency;
namespace Polly.Core.Tests.Simmy.Latency;
public static class O<|fim_suffix|>{
[Fact]
public static void Ctor_Ok()
{
// Arrange
var context = ResilienceContextPool.Shared.Get(TestCancellation.Token);
// Act
var args = new OnLatencyI... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>us<|fim_suffix|>);
}
}
<|fim_middle|>ing Polly.Simmy.Outcomes;
namespace Polly.Core.Tests.Simmy.Outcomes;
public class ChaosOutcomeConstantsTests
{
[Fact]
public void EnsureDefaults()
{
ChaosOutcomeConstants.DefaultName.ShouldBe("Chaos.Outcome");
ChaosOutcomeConstants.OnO... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.ComponentModel.DataAnnotations;
using Polly.Simmy;
using Polly.Simmy.Outcomes;
using Polly.Testing;
namespace Polly.Core.Tests.Simmy.Outcomes;
public class ChaosOutcomePipelineBuilderExtensionsTests
{
#pragma warning disable IDE0028
public static readonly TheoryData<Action<ResiliencePip... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>uldBeNull();
sut.OutcomeGenerator.ShouldBeNull();
}
}
<|fim_prefix|>using Polly.Simmy;
using Polly.Simmy.Outcomes;
namespace Polly.Core.Tests.Simmy.Outcomes;
public class ChaosOutcomeStrategyOptionsTests
{
[Fact]
public void Ctor_Ok()
{
<|fim_middle|> var sut = new ChaosO... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy.Outcomes;
using Polly.Telemetry;
namespace Polly.Core.Tests.Simmy.Outcomes;
public class ChaosOutcomeStrategyTests
{
private readonly ResilienceStrategyTelemetry _telemetry;
private readon<|fim_suffix|>his from the actual dotnet standard implementation since it is not availabl... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> var args = new OnOutcomeInjectedArguments<int>(context, new(outcome));
// Assert
args.Context.ShouldBe(context);
args.Outcome.Result.ShouldBe(outcome);
}
}
<|fim_prefix|>using Polly.Simmy.Outcomes;
namespace Polly.Core.Tests.Simmy.Outcomes;
public static class OnOutco... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>llation.Token);
// Act
var args = new OutcomeGeneratorArguments(context);
// Assert
args.Context.ShouldNotBeNull();
}
}
<|fim_prefix|>using Polly.Simmy.Outcomes;
namesp<|fim_middle|>ace Polly.Core.Tests.Simmy.Outcomes;
public static class OutcomeGeneratorArgumentsTe... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy.Outcomes;
namespace Polly.Core.Tests.Simmy.Outcomes;<|fim_suffix|>ionException>();
}
[Fact]
public void AddException_Factory_Ok()
{
var generator = new OutcomeGenerator<string>();
generator.AddException(() => new InvalidOperationException());
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy;
namespace Polly.Core.Tests.Simmy;
public sealed class TestChaosStrategy<T> : ChaosStrategy<T>
{
public TestChaosStrategy(TestChaosStrategyOptions<T> options)
: base(options)
{
}
public Action<ResilienceContext, object?>? Before { get; set; }
public Actio... | fim | App-vNext/Polly | csharp |
using Polly.Simmy;
namespace Polly.Core.Tests.Simmy;
public sealed class TestChaosStrategy : ChaosStrategy
{
public TestChaosStrategy(TestChaosStrategyOptions options)
: base(options)
{
}
public Action<ResilienceContext, object?>? Before { get; set; }
public Action<object?, Exception?>?... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Simmy;
namespace Polly.Core.Tests.Simmy;
public sealed class TestChaosStrategyOptions<T> :<|fim_suffix|>tions;
<|fim_middle|> ChaosStrategyOp<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_suffix|>olly.Core.Tests.Simmy;
public sealed class TestChaosStrategyOptions : ChaosStrategyOptions;
<|fim_prefix|>using Polly.<|fim_middle|>Simmy;
namespace P<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_suffix|>enceContextPool.Shared.Get(TestCancellation.Token);
var helper = new GeneratorHelper<int>(_ => 1000);
helper.AddOutcome(_ => Outcome.FromResult(1), 40);
var generator = helper.CreateGenerator();
generator(context).ShouldBeNull();
}
}
<|fim_prefix|>using Polly.Simmy.U... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>emetry.TelemetrySource.StrategyName.ShouldBe("strategy_name");
}
}
<|fim_prefix|>using Microsoft.Extensions.Time.Testing;
using NSubstitute;
using Polly.Telemetry;
namespace Polly.Core.Tests;
<|fim_middle|>public static class StrategyBuilderContextTests
{
[Fact]
public static void Ctor_Ensur... | fim | App-vNext/Polly | csharp |
using Polly.Telemetry;
namespace Polly.Core.Tests.Telemetry;
public class ExecutionAttemptArgumentsTests
{
[Fact]
public void Ctor_Ok()
{
var args = new ExecutionAttemptArguments(99, TimeSpan.MaxValue, true);
args.AttemptNumber.ShouldBe(99);
args.Duration.ShouldBe(TimeSpan.MaxValu... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>s.Duration.ShouldBe(TimeSpan.MaxValue);
}
}
<|fim_prefix|>using Pol<|fim_middle|>ly.Telemetry;
namespace Polly.Core.Tests.Telemetry;
public class PipelineExecutedArgumentsTests
{
[Fact]
public void Ctor_Ok()
{
var args = new PipelineExecutedArguments(TimeSpan.MaxValue);
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> }
}
<|fim_prefix|>using Polly.Telemetry;
namespace Polly.Core.Tests.Telemetry;
public class ResilienceEventTests
{
[Fact]
public void Ctor_Ok()
{
var ev = new ResilienceEvent(ResilienceEventSeverity.Warning, "A");
ev.ToString().ShouldBe("A");
ev.Severity.ShouldBe(Re... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Telemetry;
using Polly.Timeout;
namespace Polly.Core.Tests.Telemetry;
public class ResilienceStrategyTelemetryTests
{
private readonly List<TelemetryEventArguments<object, object>> _args = [];
private readonly ResilienceTelemetrySource _source;
private readonly ResilienceStrategy... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>y");
args.Context.ShouldBe(context);
args.Event.EventName.ShouldBe("ev");
args.Event.Severity.ShouldBe(ResilienceEventSeverity.Warning);
args.Source.ShouldBe(_source);
args.Arguments.ShouldBeEquivalentTo("arg");
args.Context.ShouldBe(context);
}
}
<|fim_... | fim | App-vNext/Polly | csharp |
using Polly.Telemetry;
namespace Polly.Core.Tests.Telemetry;
public static class TelemetryUtilTests
{
[Theory]
[InlineData(true, ResilienceEventSeverity.Warning)]
[InlineData(false, ResilienceEventSeverity.Information)]
public static void ReportExecutionAttempt_Ok(bool handled, ResilienceEventSeverity... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> [Fact]
public void EnsureDefaultValues() =>
TimeoutConstants.OnTimeoutEvent.ShouldBe("OnTimeout");
}
<|fim_prefix|>using Polly.Timeout;
namespace Polly.Core.Tests.Timeout;
public clas<|fim_middle|>s TimeoutConstantsTests
{
<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ldBe(timeout);
}
#endif
}
<|fim_prefix|>using Polly.Timeout;
namespace Polly.Core.Tests.Timeout;
public class TimeoutRejectedExceptionTests
{
[Fact]
public void Ctor_Ok()
{
var delay = TimeSpan.FromSeconds(4);
new TimeoutRejectedException().Message.ShouldBe("The operatio... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>or().FirstStrategy.StrategyInstance.ShouldBeOfType<TimeoutResilienceStrategy>();
}
[Fact]
public void AddTimeout_InvalidOptions_Throws() =>
Should.Throw<ValidationException>(
() => new ResiliencePipelineBuilder().AddTimeout(new TimeoutStrategyOptions { Timeout = TimeSpan.Z... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Runtime.InteropServices;
using Microsoft.Extensions.Time.Testing;
using NSubstitute;
using Polly.Telemetry;
using Polly.Timeout;
namespace Polly.Core.Tests.Timeout;
public class TimeoutResilienceStrategyTests : IDisposable
{
private readonly ResilienceStrategyTelemetry _telemetry;
p... | fim | App-vNext/Polly | csharp |
<|fim_suffix|> var options = new TimeoutStrategyOptions
{
Timeout = value
};
Should.NotThrow(
() => ValidationHelper.ValidateObject(new(options, "Dummy message")));
}
}
<|fim_prefix|>using System.ComponentModel.DataAnnotations;
using Polly.Timeout;
using Polly.Ut... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>a<TimeSpan> ValidTimeouts = new()
{
TimeSpan.FromSeconds(1),
TimeSpan.FromHours(1),
TimeSpan.FromMilliseconds(10),
};
#pragma warning restore IDE0028
}
<|fim_prefix|>using Polly.Timeout;
namespace Polly.Core.Tests.Timeout;
public static class TimeoutTestUtils
{
publi... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Timeout;
namespace Polly.Core.Tests.Timeout;
public class TimeoutUtilTests
{
public static readonly TheoryData<TimeSpan, bool> ShouldApplyTimeoutData = new()
{
{ TimeSpa<|fim_suffix|>n, false },
};
public static readonly TheoryData<TimeSpan, bool> ValidateData = new(... | fim | App-vNext/Polly | csharp |
using Microsoft.Extensions.Time.Testing;
using Polly.Utils;
namespace Polly.Core.Tests.Utils;
public class CancellationTokenSourcePoolTests
{
public static IEnumerable<object[]> TimeProviders()
{
yield return new object[] { TimeProvider.System };
yield return new object[] { new FakeTimeProvide... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>));
await Should.NotThrowAsync(async () => await DisposeHelper.TryDisposeSafeAsync(disposable, synchronous));
}
[InlineData(true)]
[InlineData(false)]
[Theory]
public async Task Dispose_EnsureCorrectOrder(bool synchronous)
{
using var disposable = new MyDisposable... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>
catch (InvalidOperationException e)
{
var oldTrace = e.StackTrace;
ExceptionUtilities.TrySetStackTrace(e);
e.StackTrace.ShouldNotBeNull();
e.StackTrace.ShouldBe(oldTrace);
}
}
}
<|fim_prefix|>using Polly.Utils;
<|fim_middle|>na... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>Properties", () => resilienceProperties.SetProperties(new Dictionary<string, object?>(), out _));
}
}
<|fim_prefix|>namespace Polly.Core.Tests.Utils;
public class LegacySupportTests
{
[Fact]
public void SetProperties_Ok()
{
var resilienceProperties = new ResilienceProperties();
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>}
[Fact]
public void CreatedByPolicy()
{
// Arrange
var policy = new ListPolicy();
var pool = new ObjectPool<List<int>>(ListPolicy.Create, ListPolicy.Return);
// Act
var list = pool.Get();
// Assert
Assert.Equal(17, list.Capacity);
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Utils;
namespace Polly.Core.Tests.Utils;
public class OutcomeUtilitiesTests
{
[Fact]
public void WithCallerCancellation_CallerCancelle<|fim_suffix|>ionToken(caller.Token);
var exception = result.Exception.ShouldBeOfType<OperationCanceledException>();
exception.Cancel... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using NSubstitute;
using Polly.Utils;
using Polly.Utils.Pipeline;
namespace Polly.Core.Tests.Utils.Pipeline;
public class BridgePipelineComponentTests
{
[Fact]
public void Ctor_Ok() =>
new Strategy<string>(args => { }).ShouldNotBeNull();
[Fact]
public void Execute_NonGeneric_Ok... | fim | App-vNext/Polly | csharp |
using NSubstitute;
using Polly.Utils.Pipeline;
namespace Polly.Core.Tests.Utils.Pipeline;
public class ComponentWithDisposeCallbacksTests
{
[Fact]
public async Task Dispose_Ok()
{
// Arrange
var called1 = 0;
var called2 = 0;
var callbacks = new List<Action>
{
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ueTask(10), context, "state").AsTask());
}
[Fact]
public void Create_EnsurePipelineReusableAcrossDifferentPipelines()
{
var components = new[]
{
PipelineComponentFactory.FromStrategy(new TestResilienceStrategy()),
Substitute.For<PipelineComponent>()... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ride ValueTask DisposeAsync() => default;
internal override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
ResilienceContext context,
TState state) => callback(context, state);
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ert.WaitOne();
}
};
await using var component = new ExecutionTrackingComponent(inner, _timeProvider);
var execution = Task.Run(() => new ResiliencePipeline(component, Polly.Utils.DisposeBehavior.Allow, null).Execute(() => { }), TestCancellation.Token);
executin... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>;
object IEnumerator.Current => null!;
public void Dispose()
{
// No-op
}
public IEnumerator<Action> GetEnumerator() => this;
public bool MoveNext() => false;
public void Reset()
{
// No-op
}
IEnu... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Threading.Tasks;
using Polly.Utils.Pipeline;
namespace Polly.Core.Tests.Utils.Pipeline;
public class PipelineComponentTests
{
[Fact]
public async Tas<|fim_suffix|>poseAsync();
}
}
<|fim_middle|>k Dispose_Ok()
{
PipelineComponent.Empty.ShouldNotBeNull();
awai... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>(0);
_listener.Events.Count(e => e.Event.EventName == "OnReload").ShouldBe(1);
}
[Fact]
public async Task ChangeTriggered_EnsureOldStrategyDisposed()
{
var telemetry = TestUtilities.CreateResilienceTelemetry(_listener);
var component = Substitute.For<PipelineCompon... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>
public void NextDouble_Ok() => Should.NotThrow(RandomUtil.NextDouble);
[Fact]
public void Next_Ok() => Should.NotThrow(() => RandomUtil.Next(42));
}
<|fim_prefix|>using Polly.Utils;
names<|fim_middle|>pace Polly.Core.Tests.Utils;
public class RandomUtilTests
{
[Fact]<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_suffix|>it Task.Delay(20);
return 42;
}
}
}
<|fim_prefix|>using Polly.Utils;
namespace Polly.Core.Tests.Utils;
public class TaskHelperTests
{
public TaskHelperTests() <|fim_middle|>=> Trace.Listeners.Clear();
[Fact]
public void GetResult_ValueTaskT_Ok()
{
var res... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ync Task DelayAsync_CancellationRequestedBefore_Throws(bool synchronous)
{
using var cts = new CancellationTokenSource();
cts.Cancel();
var delay = TimeSpan.FromMilliseconds(10);
var timeProvider = TimeProvider.System;
var context = ResilienceContextPool.Shared.... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ring, string>)).ShouldBe("KeyValuePair`2");
}
}
<|fim_prefix|>namespace Polly.Core.Tests.Utils;
public class TypeNameFormatterTests
{
[Fact]
public void AsString_Ok()
{
Polly.Utils.TypeNameFormatter.Format(typeof(string)).ShouldBe("String");
Polly.Utils.TypeNameFormatter.... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>_ => ValidationHelper.ValidateObject(new(new TestOptions(detector), string.Empty)));
detector.InvokedConcurrently.ShouldBeFalse();
}
private sealed class TestOptions(ConcurrencyDetector detector) : IValidatableObject
{
public IEnumerable<ValidationResult> Validate(ValidationC... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>
CreateProvider().GetPipeline(Key);
var diagSource = telemetry!.GetType().GetProperty("Listener", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(telemetry);
diagSource.ShouldBeOfType<TelemetryListenerImpl>();
var factory = _services.BuildServiceProvider().GetRe... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>sDisposed(limiters[0]).ShouldBeFalse();
provider.Dispose();
limiters.Count.ShouldBe(1);
IsDisposed(limiters[0]).ShouldBeTrue();
}
[Fact]
public async Task DisposePipeline_EnsureExternalPipelineNotDisposed()
{
var registry1 = new ResiliencePipelineRegistry<... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Microsoft.Extensions.DependencyInjection;
using Polly.Registry;
namespace Polly.Extensions.Tests.Issues;
public partial class IssuesTests
{
private class CustomResilienceContextPool : ResilienceContextPool
{
public override ResilienceContext Get(ResilienceContextCreationArguments ... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>t, TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
ResilienceContext context,
TState state)
{
context.Properties.Set(ServiceProviderKey, _serviceProvider);
return callback(context, state);
}
}
}... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Ne<|fim_suffix|>ed InvalidOperationException.
Should.Throw<SocketException>(() => api.ExecuteLibrary(UnstableCall));
}
void UnstableCall()
{
if (failFirstCall)
{
failFirstCall = false;
// This except... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Polly.Registry;
namespace Polly.Extensions.Tests.Issues;
public partial class IssuesTests
{
[Fact]
public void OverrideLoggerFactory_ByExplicitCon... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>alse);
await Assert.ThrowsAsync<RateLimiterRejectedException>(() => ExecuteBatch("guest-user", asserted));
asserted.Set();
#pragma warning disable CA2025
// assert admin is not limited
using var adminAsserted = new ManualResetEvent(false);
var task = ExecuteBatch("... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>he registry to allow multi-dimensional keys
services.AddResiliencePipelineRegistry<EndpointKey>(options =>
{
options.BuilderComparer = new EndpointKey.BuilderComparer();
options.PipelineComparer = new EndpointKey.StrategyComparer();
// format the key fo... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Exten<|fim_suffix|>sues;
[Collection(nameof(NonParallelizableCollection))]
public partial class IssuesTests
{
}
<|fim_middle|>sions.Tests.Is<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Extensi<|fim_suffix|>llelizableCollection), DisableParallelization = true)]
public class NonParallelizableCollection
{
}
<|fim_middle|>ons.Tests;
[CollectionDefinition(nameof(NonPara<|endoftext|> | fim | App-vNext/Polly | csharp |
using Microsoft.Extensions.Options;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using Polly.Registry;
namespace Polly.Extensions.Tests.Registry;
public class ConfigureBuilderContextExtensionsTests
{
[Fact]
public async Task ConfigureReloads_NullArguments_Throws()
{
await using var reg... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Polly.Registry;
using Polly.Telemetry;
namespace Polly.Extensions.Tests;
public class ReloadableResiliencePipelineTests
{
private static readonly ResiliencePropertyKey<string> TagKey = ... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Telemetry;
namespace Polly.Extensions.Tests.Telemetry;
[Collection(nameof(NonParallelizableCollection))]
public class TagsListTests
{
[Fact]
public async Task Pooling_OK() =>
await TestUtilities.AssertWithTimeoutAsync(() =>
{
var context = Tag<|fim_suffix|... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ckEnricher(context =>
{
for (int i = 0; i < count; i++)
{
context.Tags.Add(new KeyValuePair<string, object?>($"custom-{i}", $"custom-{i}-value"));
}
}),
new CallbackEnricher(context =>
{
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Net;
using System.Net.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using Polly.Telemetry;
namespace Polly.Extensions.Tests.Telemetry;
public class TelemetryOptionsTests
{
[Fact]
public void Ctor_EnsureDefaults()
{
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.ComponentModel.DataAnnotations;
using Micr<|fim_suffix|>ns));
}
[Fact]
public void ConfigureTelemetry_InvalidOptions_Throws()
{
var exception = Should.Throw<ValidationException>(() =>
_builder.ConfigureTelemetry(new TelemetryOptions
{
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Telemetry;
namespace Polly.Extensions.Tests.Telemetry;
public static class TelemetrySourceTests
{
[Fact]
public static void TelemetrySource_CreatesMeter()
{
var source = TelemetrySource.Instance;
sou<|fim_suffix|>ter.Version.ShouldNotContain('-');
source... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using Polly.Telemetry;
namespace Polly.Extensions.Tests.Utils;
public class TelemetryUtilTests
{
[Fact]
public void AsBoxedPool_Ok()
{
TelemetryUtil.AsBoxedBool(true).ShouldBe(true);
TelemetryUtil.AsBoxedBool(false).ShouldBe(false);
}
[Fact]
public voi<|fim_suff... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Threading.RateLimiting;
using NSubstitute;
namespace Polly.RateLimiting.Tests;
public static class OnRateLimiterRejectedArgumentsTests
{
[Fact]
public static void Ctor_Ok()
{
var args = new OnRateLimiterRejectedArguments(
Resilien<|fim_suffix|>
Su... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.RateLimiting.Tests;
public class RateLimiterConstantsTests
{
[Fact]
public void Ctor_EnsureDefaults()<|fim_suffix|>houldBe("OnRateLimiterRejected");
}
<|fim_middle|> =>
RateLimiterConstants.OnRateLimiterRejectedEvent.S<|endoftext|> | fim | App-vNext/Polly | csharp |
<|fim_suffix|>ception.TelemetrySource.ShouldBeNull();
}
#if NETFRAMEWORK
[Fact]
public void BinaryDeserialization_Ok()
{
var timeout = TimeSpan.FromSeconds(4);
var result = SerializeAndDeserializeException(new RateLimiterRejectedException(timeout));
result.RetryAfter.ShouldBe(ti... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>.AddConcurrencyLimiter(options: null!));
}
[Fact]
public async Task RegistryDispose_DoesNotDisposeExternalLimiter()
{
using var externalLimiter = new ConcurrencyLimiter(new ConcurrencyLimiterOptions
{
PermitLimit = 1,
QueueLimit = 0
});
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>using System.Threading.RateLimiting;
using NSubstitute;
using Polly.TestUtils;
namespa<|fim_suffix|>ellationToken token)
{
var result = new ValueTask<RateLimitLease>(_lease);
_limiter
.GetType()
.GetMethod("AcquireAsyncCore", BindingFlags.NonPublic | BindingFla... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>s.Name.ShouldBe("RateLimiter");
}
}
<|fim_prefix|>namespace Polly.RateLimiting.Tests;
public class RateLimiterStrategyOptionsTests
{
[Fact]
public void Ctor_EnsureDefaults()
{
var options = new RateLimiterStrategyOptions();
options.RateLimiter.ShouldBeNull();
opti... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>PassedToOnRejected!.OperationKey.ShouldBe(operationKey);
contextPassedToOnRejected!.ShouldBeSameAs(contextPassedToExecute);
}
#endregion
#region Bulkhead behaviour
protected override IBulkheadPolicy GetBulkhead(int maxParallelization, int maxQueuingActions) =>
Policy.Bul... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>Executing = cancelExecuting;
public object[] ToTheoryData() =>
[
_maxParallelization,
_maxQueuingActions,
_totalTestLoad,
_cancelQueuing,
_cancelExecuting,
_scenario
];
}
<|fim_prefix|>namespace Polly.Specs.Bulkhead;
internal readonly struct B... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>Actions: 0, totalTestLoad: 4, cancelQueuing: false, cancelExecuting: false, scenario: "A bulkhead, with no queue, oversubscribed.").ToTheoryData();
yield return new BulkheadScenario(maxParallelization: 3, maxQueuingActions: 1, totalTestLoad: 5, cancelQueuing: false, cancelExecuting: false, scenari... | fim | App-vNext/Polly | csharp |
using System.Threading.Tasks;
namespace Polly.Specs.Bulkhead;
[Collection(Constants.ParallelThreadDependentTestCollection)]
public class BulkheadSpecs(ITestOutputHelper testOutputHelper) : BulkheadSpecsBase(testOutputHelper)
{
#region Configuration
[Fact]
public void Should_throw_when_action_is_null()
... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Specs.Bulkhead;
[Collection(Constants.ParallelThreadDependentTestCollection)]
public abstract class BulkheadSpecsBase : IDisposable
{
protected static AssertionFailure? Expect(int expected, Func<int> actualFunc, string measure)
{
int actual = actualFunc();
return ... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>nnerException.ShouldBeOfType<ArgumentNullException>()
.ParamName.ShouldBe("action");
}
[Fact]
public void Should_throw_when_maxParallelization_less_or_equal_to_zero_and_no_maxQueuingActions()
{
Action policy = () => Policy
.BulkheadAsync(0);
Should... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>utOfRangeException>(policy)
.ParamName.ShouldBe("maxParallelization");
}
[Fact]
public void Should_not_throw_when_maxQueuingActions_is_int_MaxValue()
{
Action policy = () => Policy
.Bulkhead<int>(1, int.MaxValue);
policy.ShouldNotThrow();
}
... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>khead = Policy.Bulkhead(20, 10);
bulkhead.QueueAvailableCount.ShouldBe(10);
}
}
<|fim_prefix|>namespace Polly<|fim_middle|>.Specs.Bulkhead;
public class IBulkheadPolicySpecs
{
[Fact]
public void Should_be_able_to_use_BulkheadAvailableCount_via_interface()
{
var bulkhead ... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Specs.Caching;
[Collection(Constants.SystemClockDependentTestCollection)]
public class AbsoluteTtlSpecs : IDisposable
{
[Fact]
public void Should_be_able_to_configure_for_near_future_time()
{
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.UtcNow.Date.AddD... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Specs.Caching;
[Collection(Constants.SystemClockDependentTestCollection)]
public class AsyncSerializingCacheProviderSpecs
{
#region Object-to-TSerialized serializer
private static CancellationToken CancellationToken => TestCancellation.Token;
[Fact]
public void Single_g... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>(OperationKey, ValueToReturnFromCache, new Ttl(TimeSpan.MaxValue), CancellationToken, false);
bool delegateExecuted = false;
(await wrap.ExecuteAsync(async _ =>
{
delegateExecuted = true;
await TaskHelper.EmptyTask;
return ValueToReturnFromExec... | fim | App-vNext/Polly | csharp |
<|fim_suffix|>rationCanceledException>(() => policy.Execute(func, new Context(OperationKey), tokenSource.Token));
}
delegateInvocations.ShouldBe(1);
}
[Fact]
public void Should_honour_cancellation_during_delegate_execution_and_not_put_to_cache()
{
const string ValueToReturn = "... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Specs.Caching;
[Collection(Constants.SystemClockDependentTestCollection)]
public class CacheTResultAsyncSpecs : IDisposable
{
#region Configuration
private static CancellationToken CancellationToken => TestCancellation.Token;
[Fact]
public void Should_throw_when_action_... | fim | App-vNext/Polly | csharp |
<|fim_prefix|>namespace Polly.Specs.Caching;
[Collection(Constants.SystemClockDependentTestCollection)]
public class CacheTResultSpecs : IDisposable
{
#region Configuration
[Fact]
public void Should_throw_when_action_is_null()
{
var flags = BindingFlags.NonPublic | BindingFlags.Instance;
... | fim | App-vNext/Polly | csharp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.