public async Task TestThatNotAllExceptionsAreRetried() { var updateSessionStub = new StubIUpdateSessionManager() .TryStartUpdateSession(() => AsyncUtils.AsyncTaskThatThrows <bool>(new Exception())); IUpdateSessionManager retryDecorator = new StorageExceptionUpdateSessionRetryDecorator( updateSessionStub, new FixedInterval(1, TimeSpan.Zero), new StorageExceptionErrorDetectionStrategy()); await Assert.ThrowsAsync <Exception>(async() => await retryDecorator.TryStartUpdateSession()); }
public async Task TestThatExceptionIsThrownIfMaxRetryCountIsReached() { var sequence = StubsUtils.Sequence <StubIUpdateSessionManager.TryStartUpdateSession_Delegate>() .Twice(() => AsyncUtils.AsyncTaskThatThrows <bool>(new StorageException())) .Once(() => AsyncUtils.AsyncTaskWithResult(true)); var updateSessionStub = new StubIUpdateSessionManager() .TryStartUpdateSession(() => sequence.Next()); IUpdateSessionManager retryDecorator = new StorageExceptionUpdateSessionRetryDecorator( updateSessionStub, new FixedInterval(1, TimeSpan.Zero), new StorageExceptionErrorDetectionStrategy()); await Assert.ThrowsAsync <StorageException>(async() => await retryDecorator.TryStartUpdateSession()); }
public async Task TestThatStartUpdateSessionIsRetried() { string appId = "appId"; var sequence = StubsUtils.Sequence <StubIUpdateSessionManager.TryStartUpdateSession_String_Delegate>() .Once(id => AsyncUtils.AsyncTaskThatThrows <bool>(new StorageException())) .Once(id => AsyncUtils.AsyncTaskWithResult(true)); var updateSessionStub = new StubIUpdateSessionManager() .TryStartUpdateSession(id => sequence.Next(id)); IUpdateSessionManager retryDecorator = new StorageExceptionUpdateSessionRetryDecorator( updateSessionStub, new FixedInterval(1, TimeSpan.Zero), new StorageExceptionErrorDetectionStrategy()); Assert.True(await retryDecorator.TryStartUpdateSession(appId)); }