Example #1
0
        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());
        }
Example #2
0
        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());
        }
Example #3
0
        public async Task TestThatEndUpdateSessionIsRetried()
        {
            var sequence = StubsUtils.Sequence <StubIUpdateSessionManager.EndUpdateSession_Delegate>()
                           .Once(() => AsyncUtils.AsyncTaskThatThrows(new StorageException()))
                           .Once(() => Task.CompletedTask);

            var updateSessionStub = new StubIUpdateSessionManager()
                                    .EndUpdateSession(() => sequence.Next());

            IUpdateSessionManager retryDecorator = new StorageExceptionUpdateSessionRetryDecorator(
                updateSessionStub,
                new FixedInterval(1, TimeSpan.Zero),
                new StorageExceptionErrorDetectionStrategy());
            await retryDecorator.EndUpdateSession();
        }
        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));
        }