public void ExecutesPolicy() { var impl = new Service(); var executed = false; var provider = new CallbackPolicyProvider((method, arguments) => executed = true); var proxy = PollyWrapper <IService> .Decorate(impl, provider, new ContextProvider()); proxy.Greeting = HelloWorld; executed.ShouldBeTrue(); }
public async Task ExecutesPolicy() { var impl = new Service(); var executed = false; var provider = new CallbackPolicyProvider((method, arguments) => executed = true); var proxy = PollyWrapper <IService> .Decorate(impl, provider, new ContextProvider()); var result = await proxy.EchoAsync(HelloWorld); executed.ShouldBeTrue(); }
public void ExecutesPolicy() { var output = new StringWriter(); var impl = new Service(output); var executed = false; var provider = new CallbackPolicyProvider((method, arguments) => executed = true); var proxy = PollyWrapper <IService> .Decorate(impl, provider, new ContextProvider()); proxy.SayHelloWorld <string>(); executed.ShouldBeTrue(); }
public void WithPolicy() { var impl = new Service(); var executed = 0; var provider = new CallbackPolicyProvider((method, arguments) => executed++); var proxy = PollyWrapper <IService> .Decorate(impl, provider, new ContextProvider()); proxy.Greeting = HelloWorld; var result = proxy.Greeting; result.ShouldBe(HelloWorld); }
public void ExecutesPolicy() { var impl = new Service(); var executed = false; var policyProvider = new CallbackPolicyProvider((method, arguments) => executed = true); var contextProvider = new ContextProvider(); var proxy = PollyWrapper <IService> .Decorate(impl, policyProvider, contextProvider); var result = proxy[HelloWorld]; result.ShouldBe(HelloWorld); executed.ShouldBeTrue(); }
public async Task ExecutesPolicy() { var impl = new Throw(); var executed = false; var provider = new CallbackPolicyProvider((method, arguments) => executed = true); var proxy = PollyWrapper <IThrow> .Decorate(impl, provider, new ContextProvider()); try { await proxy.ThrowException(); } catch { } executed.ShouldBeTrue(); }