Ejemplo n.º 1
0
 public WhenSyncSucceeds()
 {
     SyncManager.ForceFullSync().Returns(Observable.Return(SyncState.Sleep));
     SyncManager.PullTimeEntries().Returns(Observable.Return(SyncState.Sleep));
     SyncManager.PushSync().Returns(Observable.Return(SyncState.Sleep));
     SyncManager.CleanUp().Returns(Observable.Return(SyncState.Sleep));
 }
Ejemplo n.º 2
0
 public WhenSyncFails()
 {
     SyncManager.ForceFullSync().Returns(Observable.Throw <SyncState>(new Exception()));
     SyncManager.PullTimeEntries().Returns(Observable.Throw <SyncState>(new Exception()));
     SyncManager.PushSync().Returns(Observable.Throw <SyncState>(new Exception()));
     SyncManager.CleanUp().Returns(Observable.Throw <SyncState>(new Exception()));
 }
Ejemplo n.º 3
0
        public IObservable <Unit> StartSyncing()
        {
            if (isLoggedIn == false)
            {
                throw new InvalidOperationException("Cannot start syncing after the user logged out of the app.");
            }

            if (signalDisposable != null || midnightDisposable != null)
            {
                throw new InvalidOperationException("The StartSyncing method has already been called.");
            }

            signalDisposable = backgroundService.AppResumedFromBackground
                               .Where(timeInBackground => timeInBackground >= minimumTimeInBackgroundForFullSync)
                               .Subscribe((TimeSpan _) => SyncManager.ForceFullSync());

            midnightDisposable = timeService.MidnightObservable
                                 .Subscribe((DateTimeOffset _) => SyncManager.CleanUp());

            return(SyncManager.ForceFullSync()
                   .Select(_ => Unit.Default));
        }
Ejemplo n.º 4
0
 public void TracksSyncOperationStarted()
 {
     SyncManager.CleanUp();
     AnalyticsService.Received().SyncOperationStarted.Track(SyncState.CleanUp.ToString());
 }
Ejemplo n.º 5
0
 protected override IObservable <SyncState> CallSyncMethod()
 => SyncManager.CleanUp();