示例#1
0
            public void SavesTheTimeOfSyncAttempt(DateTimeOffset now)
            {
                TimeService.CurrentDateTime.Returns(now);

                SyncManager.ForceFullSync();
                OrchestratorStates.OnNext(Pull);

                LastTimeUsageStorage.Received().SetFullSyncAttempt(now);
            }
示例#2
0
            public void SavesTheTimeOfSuccessfulFullSync(DateTimeOffset now)
            {
                TimeService.CurrentDateTime.Returns(now);

                var observable = SyncManager.ForceFullSync();

                OrchestratorStates.OnNext(Pull);
                OrchestratorStates.OnNext(Sleep);
                observable.Wait();

                LastTimeUsageStorage.Received().SetSuccessfulFullSync(now);
            }
示例#3
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();
            }
示例#4
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 ReturnsObservableThatReplaysSyncStatesUntilSleep(bool[] beforeSleep, bool[] afterSleep)
            {
                var observable = CallSyncMethod();
                
                var beforeSleepStates = (beforeSleep ?? Enumerable.Empty<bool>())
                    .Select(b => b ? Push : Pull);
                var afterSleepStates = (afterSleep ?? Enumerable.Empty<bool>())
                    .Select(b => b ? Push : Pull);

                var expectedStates = beforeSleepStates.Concat(new[] { Sleep }).ToList();

                foreach (var states in expectedStates.Concat(afterSleepStates))
                    OrchestratorStates.OnNext(states);

                var actual = observable.ToList().Wait();

                actual.ShouldBeEquivalentTo(expectedStates);
            }