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