public void CustomMediaRetryPolicyTestExceededMaxRetryAttempts() { MediaRetryPolicy target = new TestMediaServicesClassFactoryForCustomRetryPolicy(null).GetBlobStorageClientRetryPolicy(); int exceptionCount = 4; int expected = 10; //This is the new exception included for retrypolicy in the customretrypolicy var fakeException = new IOException("CustomRetryPolicyException"); Func <int> func = () => { if (--exceptionCount > 0) { throw fakeException; } return(expected); }; try { target.ExecuteAction(func); } catch (AggregateException ax) { IOException x = (IOException)ax.Flatten().InnerException; Assert.AreEqual(1, exceptionCount); Assert.AreEqual(fakeException, x); //Exception is retried only for max retrial attempts, //In this case there are max of 2 attempts for blob retry policy. Assert.AreEqual(exceptionCount, 1); throw; } }
public void CustomMediaRetryPolicyTestExecuteActionTrivial() { MediaRetryPolicy target = new TestMediaServicesClassFactoryForCustomRetryPolicy(null).GetSaveChangesRetryPolicy(null); int expected = 10; Func <int> func = () => expected; int actual = target.ExecuteAction(func); Assert.AreEqual(expected, actual); }
public void CustomMediaRetryPolicyTestExecuteActionRetry() { MediaRetryPolicy target = new TestMediaServicesClassFactoryForCustomRetryPolicy(null).GetSaveChangesRetryPolicy(null); int exceptionCount = 3; int expected = 10; //This is the new exception included for retrypolicy in the customretrypolicy var fakeException = new IOException("CustomRetryPolicyException"); Func <int> func = () => { if (--exceptionCount > 0) { throw fakeException; } return(expected); }; int actual = target.ExecuteAction(func); Assert.AreEqual(expected, actual); Assert.AreEqual(0, exceptionCount); }