public void PersistentFailureTest() { this.iteration = 0; Aspect retryAspect = new RetryCountAspect(3); this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureNTimes(3, true)); }
public void AbortedRetryTest() { this.iteration = 0; Aspect retryAspect = new RetryCountAspect(3, 100); // A thread simulating asynchronous application exit. Task asyncAbortGenerator = Task.Factory.StartNew(() => { Thread.Sleep(100); Threading.ApplicationExiting.Set(); }); InstanceProxy <RetryAspectsTest> proxy = this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)); try { proxy.Invoke(test => test.SimulateFailureNTimes(3, true)); } finally { Threading.ApplicationExiting.Reset(); bool aborted = proxy.callLog.Exists(l => l.Key == "Retry Aborted"); Assert.IsTrue(aborted); asyncAbortGenerator.Wait(); } }
public void SuccessAfterRetryTest() { #pragma warning disable 219 this.iteration = 0; Aspect retryAspect = new RetryCountAspect(3); DateTime dt = (DateTime)this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureNTimes(2, true)); this.testStart = DateTime.UtcNow; retryAspect = new RetryTimeAspect(300, 100); // ReSharper disable once RedundantAssignment dt = (DateTime)this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureFor(200, true)); this.iteration = 0; retryAspect = new RetryCountAspect(3, 50, proxy => proxy.ReturnedValue == null); // ReSharper disable once RedundantAssignment dt = (DateTime)this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureNTimes(2, false)); this.testStart = DateTime.UtcNow; retryAspect = new RetryTimeAspect(300, 100, proxy => proxy.ReturnedValue == null); // ReSharper disable once RedundantAssignment dt = (DateTime)this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureFor(200, false)); this.testStart = DateTime.UtcNow; retryAspect = new RetryExponentialDelayAspect(300, 10, 2.5, proxy => proxy.ReturnedValue == null); // ReSharper disable once RedundantAssignment dt = (DateTime)this.GetProxy(AspectacularTest.MoreTestAspects(retryAspect)).Invoke(test => test.SimulateFailureFor(200, false)); #pragma warning restore 219 }