/// <exception cref="System.Exception"></exception> public virtual void TestChangeTrackerInvalidJson() { Uri testURL = GetReplicationURL(); CustomizableMockHttpClient mockHttpClient = new CustomizableMockHttpClient(); mockHttpClient.AddResponderThrowExceptionAllRequests(); ChangeTrackerClient client = new _ChangeTrackerClient_290(mockHttpClient); ChangeTracker changeTracker = new ChangeTracker(testURL, ChangeTracker.ChangeTrackerMode .LongPoll, 0, client); BackgroundTask task = new _BackgroundTask_311(changeTracker); task.Execute(); try { // expected behavior: // when: // mockHttpClient throws IOExceptions -> it should start high and then back off and numTimesExecute should be low for (int i = 0; i < 30; i++) { int numTimesExectutedAfter10seconds = 0; try { Sharpen.Thread.Sleep(1000); // take a snapshot of num times the http client was called after 10 seconds if (i == 10) { numTimesExectutedAfter10seconds = mockHttpClient.GetCapturedRequests().Count; } // take another snapshot after 20 seconds have passed if (i == 20) { // by now it should have backed off, so the delta between 10s and 20s should be small int delta = mockHttpClient.GetCapturedRequests().Count - numTimesExectutedAfter10seconds; NUnit.Framework.Assert.IsTrue(delta < 25); } } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } } } finally { changeTracker.Stop(); } }