public void SavesTheTimeOfSyncAttempt(DateTimeOffset now) { TimeService.CurrentDateTime.Returns(now); SyncManager.ForceFullSync(); OrchestratorStates.OnNext(Pull); LastTimeUsageStorage.Received().SetFullSyncAttempt(now); }
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); }
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 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); }