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));
 }
 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()));
 }
        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));
        }
示例#4
0
 public void TracksSyncOperationStarted()
 {
     SyncManager.CleanUp();
     AnalyticsService.Received().SyncOperationStarted.Track(SyncState.CleanUp.ToString());
 }
示例#5
0
 protected override IObservable <SyncState> CallSyncMethod()
 => SyncManager.CleanUp();