public void DoesNotThrowWhenFreezingAFrozenSyncManager() { SyncManager.Freeze(); Action freezing = () => SyncManager.Freeze(); freezing.Should().NotThrow(); }
public IObservable <Unit> Logout() => SyncManager.Freeze() .FirstAsync() .Do(_ => isLoggedIn = false) .Do(_ => stopSyncingOnSignal()) .SelectMany(_ => database.Clear()) .Do(_ => shortcutCreator.OnLogout()) .FirstAsync();
public void FreezingSyncManagerWhenNoSyncIsRunningImmediatellyReturnsSleep() { SyncState?firstState = null; var observable = SyncManager.Freeze(); var subscription = observable.Subscribe(state => firstState = state); firstState.Should().Be(Sleep); }
public void RunningFullSyncOnFrozenSyncManagerGoesDirectlyToSleepState() { SyncManager.Freeze(); SyncManager.ForceFullSync(); Orchestrator.Received(1).Start(Arg.Is(Sleep)); Orchestrator.DidNotReceive().Start(Arg.Is(Push)); Orchestrator.DidNotReceive().Start(Arg.Is(Pull)); }
public IObservable <Unit> Logout() => SyncManager.Freeze() .FirstAsync() .Do(_ => isLoggedIn = false) .SelectMany(_ => database.Clear()) .Do(shortcutCreator.OnLogout) .SelectMany(_ => notificationService .UnscheduleAllNotifications() .Catch(Observable.Return(Unit.Default))) .FirstAsync();
public void DoesNotClearTheDatabaseBeforeTheSyncManagerCompletesFreezing() { var scheduler = new TestScheduler(); SyncManager.Freeze().Returns(Observable.Never <SyncState>()); var observable = interactor.Execute().SubscribeOn(scheduler).Publish(); observable.Connect(); scheduler.AdvanceBy(TimeSpan.FromDays(1).Ticks); Database.DidNotReceive().Clear(); }
public void CompletesWhenSleepStateOccursAfterPushSync() { bool finished = false; SyncManager.PushSync(); var observable = SyncManager.Freeze().Subscribe(_ => finished = true); OrchestratorStates.OnNext(Push); OrchestratorStates.OnNext(Sleep); SyncManager.IsRunningSync.Should().BeFalse(); finished.Should().BeTrue(); }
public void KeepsWaitingWhileNoSleepStateOccursAfterPushSync() { bool finished = false; Queue.Dequeue().Returns(Push); SyncManager.PushSync(); var observable = SyncManager.Freeze().Subscribe(_ => finished = true); OrchestratorStates.OnNext(Push); SyncManager.IsRunningSync.Should().BeTrue(); finished.Should().BeFalse(); }
public void ClearTheDatabaseOnlyOnceTheSyncManagerFreezeEmitsAValueEvenThoughItDoesNotComplete() { var freezingSubject = new Subject <SyncState>(); SyncManager.Freeze().Returns(freezingSubject.AsObservable()); var observable = interactor.Execute().Publish(); observable.Connect(); Database.DidNotReceive().Clear(); freezingSubject.OnNext(SyncState.Sleep); Database.Received().Clear(); }
public void EmitsUnitValueAndCompletesWhenFreezeAndDatabaseClearEmitSingleValueButDoesNotComplete() { var clearingSubject = new Subject <Unit>(); SyncManager.Freeze().Returns(_ => Observable.Return(SyncState.Sleep)); Database.Clear().Returns(clearingSubject.AsObservable()); bool emitsUnitValue = false; bool completed = false; var observable = interactor.Execute(); observable.Subscribe( _ => emitsUnitValue = true, () => completed = true); clearingSubject.OnNext(Unit.Default); emitsUnitValue.Should().BeTrue(); completed.Should().BeTrue(); }
public void DisablesAutomaticSyncing() { SyncManager.Freeze(); AutomaticSyncingService.Received().Stop(); }