Example #1
0
            public void DoesNotThrowWhenFreezingAFrozenSyncManager()
            {
                SyncManager.Freeze();

                Action freezing = () => SyncManager.Freeze();

                freezing.Should().NotThrow();
            }
Example #2
0
 public IObservable <Unit> Logout()
 => SyncManager.Freeze()
 .FirstAsync()
 .Do(_ => isLoggedIn = false)
 .Do(_ => stopSyncingOnSignal())
 .SelectMany(_ => database.Clear())
 .Do(_ => shortcutCreator.OnLogout())
 .FirstAsync();
Example #3
0
            public void FreezingSyncManagerWhenNoSyncIsRunningImmediatellyReturnsSleep()
            {
                SyncState?firstState = null;

                var observable   = SyncManager.Freeze();
                var subscription = observable.Subscribe(state => firstState = state);

                firstState.Should().Be(Sleep);
            }
Example #4
0
            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));
            }
Example #5
0
 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();
        }
Example #7
0
            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();
            }
Example #8
0
            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();
        }
Example #11
0
            public void DisablesAutomaticSyncing()
            {
                SyncManager.Freeze();

                AutomaticSyncingService.Received().Stop();
            }