Beispiel #1
0
            public async Task ShowsTheReLoginViewIfTheUserRevokedTheApiToken()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);

                await Task.Run(() => AppStart.Start());

                await SyncManager.DidNotReceive().ForceFullSync();

                await NavigationService.Received().Navigate <TokenResetViewModel>();
            }
Beispiel #2
0
            public async Task SubscribesToTheMidnightObservable()
            {
                var errors = new Subject <Exception>();

                SyncManager.Errors.Returns(errors);

                errors.OnNext(new Exception());
                AppResumedFromBackground.OnNext(TimeSpan.FromHours(1));

                await SyncManager.DidNotReceive().ForceFullSync();
            }
Beispiel #3
0
            public async Task DoesNotInitiatePushSyncWhenStartingFails()
            {
                var observable = Observable.Throw <IThreadSafeTimeEntry>(new Exception());

                DataSource.TimeEntries.Create(Arg.Any <IThreadSafeTimeEntry>())
                .Returns(observable);

                Action executeCommand =
                    () => CallInteractor(CreatePrototype(ValidTime, ValidDescription, true, ProjectId)).Wait();

                executeCommand.Should().Throw <Exception>();
                await SyncManager.DidNotReceive().PushSync();
            }
            public async ThreadingTask UnsubscribesFromTheSignalAfterLogout()
            {
                var subject = new Subject <TimeSpan>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                await DataSource.StartSyncing();

                SyncManager.ClearReceivedCalls();
                await DataSource.Logout();

                subject.OnNext(MinimumTimeInBackgroundForFullSync + TimeSpan.FromSeconds(1));

                await SyncManager.DidNotReceive().ForceFullSync();
            }
Beispiel #5
0
            public void UnsubscribesFromTheBackgroundServiceObservableWhenExceptionIsCaught()
            {
                var subject       = new Subject <TimeSpan>();
                var errorsSubject = new Subject <Exception>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                SyncManager.Errors.Returns(errorsSubject);

                AutomaticSyncingService.SetupAutomaticSync(UserAccessManager);
                LoggedIn.OnNext(DataSource);
                SyncManager.ClearReceivedCalls();
                errorsSubject.OnNext(new Exception());
                subject.OnNext(MinimumTimeInBackgroundForFullSync);

                SyncManager.DidNotReceive().ForceFullSync();
            }
            public void UnsubscribesFromTheBackgroundServiceObservableWhenExceptionIsCaught()
            {
                var subject = new Subject <TimeSpan>();

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

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

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

                SyncManager.DidNotReceive().ForceFullSync();
            }
            public async ThreadingTask DoesNotInitiatePushSyncWhenSavingFails()
            {
                InteractorFactory
                .StopTimeEntry(Arg.Any <DateTimeOffset>(), Arg.Any <TimeEntryStopOrigin>())
                .Execute()
                .Returns(Observable.Throw <IThreadSafeTimeEntry>(new Exception()));

                var errors = TestScheduler.CreateObserver <Exception>();

                ViewModel.StopTimeEntry.Errors.Subscribe(errors);
                ViewModel.StopTimeEntry.Execute(Arg.Any <TimeEntryStopOrigin>());

                TestScheduler.Start();

                errors.Messages.Count().Should().Be(1);
                SyncManager.DidNotReceive().PushSync();
            }
Beispiel #8
0
            public async Task UnsubscribesFromTheSignalWhenStopped()
            {
                var subject = new Subject <TimeSpan>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                var errors = Observable.Never <Exception>();

                SyncManager.Errors.Returns(errors);

                AutomaticSyncingService.Start(SyncManager);
                SyncManager.ClearReceivedCalls();
                AutomaticSyncingService.Stop();

                subject.OnNext(Foundation.Services.AutomaticSyncingService.MinimumTimeInBackgroundForFullSync);

                await SyncManager.DidNotReceive().ForceFullSync();
            }
Beispiel #9
0
            public async Task UnsubscribesFromTheSignalAfterLogout()
            {
                var subject = new Subject <TimeSpan>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                var errors = Observable.Never <Exception>();

                SyncManager.Errors.Returns(errors);

                AutomaticSyncingService.SetupAutomaticSync(UserAccessManager);
                LoggedIn.OnNext(DataSource);
                SyncManager.ClearReceivedCalls();
                LoggedOut.OnNext(Unit.Default);

                subject.OnNext(MinimumTimeInBackgroundForFullSync);

                await SyncManager.DidNotReceive().ForceFullSync();
            }