Ejemplo n.º 1
0
        public async Task TestThatNotAllExceptionsAreRetried()
        {
            string appId             = "appId";
            var    updateSessionStub = new StubIUpdateSessionManager()
                                       .TryStartUpdateSession(id => AsyncUtils.AsyncTaskThatThrows <bool>(new Exception()));

            IUpdateSessionManager retryDecorator = new UpdateSessionManagerRetryDecorator(
                updateSessionStub,
                new FixedInterval(1, TimeSpan.Zero),
                new StorageExceptionErrorDetectionStrategy());
            await Assert.ThrowsAsync <Exception>(async() => await retryDecorator.TryStartUpdateSession(appId));
        }
Ejemplo n.º 2
0
        public async Task TestThatEndUpdateSessionIsRetried()
        {
            string appId    = "appId";
            var    sequence = StubsUtils.Sequence <StubIUpdateSessionManager.EndUpdateSession_String_Delegate>()
                              .Once(id => AsyncUtils.AsyncTaskThatThrows(new StorageException()))
                              .Once(id => Task.CompletedTask);

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

            IUpdateSessionManager retryDecorator = new UpdateSessionManagerRetryDecorator(
                updateSessionStub,
                new FixedInterval(1, TimeSpan.Zero),
                new StorageExceptionErrorDetectionStrategy());
            await retryDecorator.EndUpdateSession(appId);
        }
Ejemplo n.º 3
0
        public async Task TestThatExceptionIsThrownIfMaxRetryCountIsReached()
        {
            string appId = "appId";

            var sequence = StubsUtils.Sequence <StubIUpdateSessionManager.TryStartUpdateSession_String_Delegate>()
                           .Twice(id => AsyncUtils.AsyncTaskThatThrows <bool>(new StorageException()))
                           .Once(id => AsyncUtils.AsyncTaskWithResult(true));

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

            IUpdateSessionManager retryDecorator = new UpdateSessionManagerRetryDecorator(
                updateSessionStub,
                new FixedInterval(1, TimeSpan.Zero),
                new StorageExceptionErrorDetectionStrategy());
            await Assert.ThrowsAsync <StorageException>(async() => await retryDecorator.TryStartUpdateSession(appId));
        }