public void TestSmartRunnerStrategyCatchInheritedException() { int i = 0; // SystemException is parent of NullReferenceException RunWithRetry.Run <SystemException>( () => { i++; throw new NullReferenceException(i.ToString()); }, 2, 0); Assert.AreEqual(2, i); }
public void TestTryToRunTwiceIfParamIsTwo() { int i = 0; RunWithRetry.Run <NullReferenceException>( () => { i++; if (i == 1) { throw new NullReferenceException(); } }, 2, 0); Assert.AreEqual(2, i); }
public void TestSmartRunnerThrowExactlyThrowedException() { int i = 0; try { RunWithRetry.Run <NullReferenceException>( () => { i++; throw new NullReferenceException(i.ToString()); }, 2, 0); } catch (NullReferenceException e) { Assert.AreEqual(e.Message, "3"); } Assert.AreEqual(3, i); }
public void ClearMachinesCache(string appName) { if (string.IsNullOrEmpty(appName)) { return; } logger.Log("FarmNormal", null, transport.SubscriberID, null, 3, "Send Message for app " + appName); try { RunWithRetry.Run <PublishSyncTimeoutException>( () => { this.transport.PublishSync(new FarmMessage { AppName = appName, Time = DateTime.Now }); }, 3, 200); } catch (PublishSyncTimeoutException exception) { logger.Log("FarmNormal", null, transport.SubscriberID, exception, 1, "Publish failed for app " + appName); } }