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)); }
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(); }
public void DoesNotNavigateForDifferentExceptions() { ErrorHandlingService.TryHandleUnauthorizedError(exception); NavigationService.DidNotReceive().Navigate <TokenResetViewModel>(); }
public void DoesNotRestrictAccessForDifferentExceptions() { ErrorHandlingService.TryHandleUnauthorizedError(exception); AccessRestrictionStorage.DidNotReceive().SetUnauthorizedAccess(Arg.Any <string>()); }
public void NavigatesToOutdatedAppViewModelForClientDeprecatedException() { ErrorHandlingService.TryHandleUnauthorizedError(exception); NavigationService.Received().Navigate <TokenResetViewModel>(); }
public void RestricsAccessForClientDeprecatedException() { ErrorHandlingService.TryHandleUnauthorizedError(exception); AccessRestrictionStorage.Received().SetUnauthorizedAccess(Arg.Is(User.ApiToken)); }
public void ReturnsTrueForClientDeprecatedException() { var result = ErrorHandlingService.TryHandleUnauthorizedError(exception); result.Should().BeTrue(); }