Upstream App-vNext/Polly state of the touched files before 65d060c90f
This commit is contained in:
commit
7121d2323f
2 files changed
+133
No files matched your search
@@ -0,0 +1,50 @@
|
||||
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).ShouldBeOfType<InvalidOperationException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddException_Factory_Ok()
|
||||
{
|
||||
var generator = new FaultGenerator();
|
||||
|
||||
generator.AddException(() => new InvalidOperationException());
|
||||
|
||||
Generate(generator).ShouldBeOfType<InvalidOperationException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddException_FactoryWithResilienceContext_Ok()
|
||||
{
|
||||
var generator = new FaultGenerator();
|
||||
|
||||
generator.AddException(context =>
|
||||
{
|
||||
context.ShouldNotBeNull();
|
||||
|
||||
return new InvalidOperationException();
|
||||
});
|
||||
|
||||
Generate(generator).ShouldBeOfType<InvalidOperationException>();
|
||||
}
|
||||
|
||||
private static Exception? Generate(FaultGenerator generator)
|
||||
{
|
||||
Func<FaultGeneratorArguments, ValueTask<Exception?>> func = generator;
|
||||
|
||||
return func(
|
||||
new FaultGeneratorArguments(
|
||||
ResilienceContextPool.Shared.Get(TestCancellation.Token))).AsTask().Result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user