public void DoesNotThrowForAnyExceptionWhichCanBeThrownByTheProgressObservable(Exception exception)
            {
                ErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);
                ErrorHandlingService.TryHandleDeprecationError(Arg.Any <ClientDeprecatedException>()).Returns(true);
                ErrorHandlingService.TryHandleDeprecationError(Arg.Any <ApiDeprecatedException>()).Returns(true);

                Action processingError = () => ProgressSubject.OnError(exception);

                processingError.Should().NotThrow();
            }
            public async ThreadingTask SetsTheUnauthorizedAccessFlag()
            {
                var exception = new UnauthorizedException(request, response);

                ErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);

                ProgressSubject.OnError(exception);

                ErrorHandlingService.Received().TryHandleUnauthorizedError(Arg.Is(exception));
            }
Exemple #3
0
            internal void ReturnsTrueButDoesNotNavigateOrSetUnathorizedAccessFlagWhenTheApiTokenCannotBeExtractedFromTheRequest()
            {
                var request = Substitute.For <IRequest>();

                request.Headers.Returns(new HttpHeader[0]);
                var exceptionWithoutApiToken = new UnauthorizedException(request, Substitute.For <IResponse>());

                var handled = ErrorHandlingService.TryHandleUnauthorizedError(exceptionWithoutApiToken);

                handled.Should().BeTrue();
                NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();
                AccessRestrictionStorage.DidNotReceive().SetUnauthorizedAccess(Arg.Any <string>());
            }
            public void UnsubscribesFromTheBackgroundServiceObservableWhenExceptionIsCaught()
            {
                var subject = new Subject <TimeSpan>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                DataSource.StartSyncing();
                SyncManager.ClearReceivedCalls();
                var exception = new UnauthorizedException(request, response);

                ErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);

                ProgressSubject.OnError(exception);
                subject.OnNext(MinimumTimeInBackgroundForFullSync + TimeSpan.FromSeconds(1));

                SyncManager.DidNotReceive().ForceFullSync();
            }
Exemple #5
0
            public void DoesNotNavigateForDifferentExceptions()
            {
                ErrorHandlingService.TryHandleUnauthorizedError(exception);

                NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();
            }
Exemple #6
0
            public void DoesNotRestrictAccessForDifferentExceptions()
            {
                ErrorHandlingService.TryHandleUnauthorizedError(exception);

                AccessRestrictionStorage.DidNotReceive().SetUnauthorizedAccess(Arg.Any <string>());
            }
Exemple #7
0
            public void NavigatesToOutdatedAppViewModelForClientDeprecatedException()
            {
                ErrorHandlingService.TryHandleUnauthorizedError(exception);

                NavigationService.Received().Navigate <TokenResetViewModel>();
            }
Exemple #8
0
            public void RestricsAccessForClientDeprecatedException()
            {
                ErrorHandlingService.TryHandleUnauthorizedError(exception);

                AccessRestrictionStorage.Received().SetUnauthorizedAccess(Arg.Is(User.ApiToken));
            }
Exemple #9
0
            public void ReturnsTrueForClientDeprecatedException()
            {
                var result = ErrorHandlingService.TryHandleUnauthorizedError(exception);

                result.Should().BeTrue();
            }