public void ReportsErrorToTheAnalyticsService() { var exception = new Exception(); OrchestratorSyncComplete.OnNext(new Error(exception)); AnalyticsService.Received().TrackAnonymized(exception); }
public void ReportsOfflineExceptionsToTheAnalyticsServiceAsANormalEvent() { var exception = new OfflineException(); OrchestratorSyncComplete.OnNext(new Error(exception)); AnalyticsService.OfflineModeDetected.Received().Track(); }
public void DoNotReportOfflineExceptionsToTheAnalyticsService() { var exception = new OfflineException(); OrchestratorSyncComplete.OnNext(new Error(exception)); AnalyticsService.DidNotReceive().TrackSyncError(Arg.Any <Exception>()); }
public void TracksSyncError() { var exception = new Exception(); OrchestratorSyncComplete.OnNext(new Error(exception)); AnalyticsService.Received().TrackAnonymized(exception); AnalyticsService.Received().SyncFailed.Track(exception.GetType().FullName, exception.Message, exception.StackTrace); }
public void EmitsFailedWhenSyncFailsWithUnknownException() { SyncProgress?emitted = null; OrchestratorSyncComplete.OnNext(new Error(new Exception())); SyncManager.ProgressObservable.Subscribe(progress => emitted = progress); emitted.Should().NotBeNull(); emitted.Should().Be(SyncProgress.Failed); }
public void DoesNotPreventFurtherSyncingAfterAnErrorWasReported() { OrchestratorSyncComplete.OnNext(new Error(new Exception())); Orchestrator.ClearReceivedCalls(); Queue.When(q => q.QueuePushSync()).Do(_ => Queue.Dequeue().Returns(Push)); SyncManager.PushSync(); Orchestrator.Received().Start(Arg.Is(Push)); }
public void DoesNotTellQueueToStartOrchestratorWhenInSecondPartOfMultiPhaseSync() { Queue.Dequeue().Returns(Pull); SyncManager.ForceFullSync(); OrchestratorSyncComplete.OnNext(new Success(Push)); Queue.ClearReceivedCalls(); CallMethod(); Queue.DidNotReceive().Dequeue(); }
public void ReportsTheErrorWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception) { Exception caughtException = null; SyncManager.Errors.Subscribe(e => caughtException = e); OrchestratorSyncComplete.OnNext(new Error(exception)); caughtException.Should().NotBeNull(); caughtException.Should().Be(exception); }
public void TracksSyncCompleted() { SyncProgress?emitted = null; Queue.Dequeue().Returns(Sleep); OrchestratorSyncComplete.OnNext(new Success(Pull)); SyncManager.ProgressObservable.Subscribe(progress => emitted = progress); AnalyticsService.Received().SyncCompleted.Track(); }
public void TellsQueueToStartOrchestratorWhenInSecondPartOfMultiPhaseSync() { Queue.StartNextQueuedState(Orchestrator).Returns(Pull); SyncManager.ForceFullSync(); OrchestratorSyncComplete.OnNext(Push); Queue.ClearReceivedCalls(); CallMethod(); Queue.Received().StartNextQueuedState(Orchestrator); }
public void EmitsNoDefaultWorkspaceErrorWhenSyncFailsWithNoDefaultWorkspaceException() { Exception caughtException = null; var thrownException = new NoDefaultWorkspaceException(); SyncManager.Errors.Subscribe(e => caughtException = e); OrchestratorSyncComplete.OnNext(new Error(thrownException)); caughtException.Should().BeSameAs(thrownException); }
public void EmitsTheLastValueAfterSubscribing() { SyncProgress?emitted = null; OrchestratorSyncComplete.OnNext(new Error(new Exception())); SyncManager.ProgressObservable.Subscribe(progress => emitted = progress); emitted.Should().NotBeNull(); emitted.Should().Be(SyncProgress.Failed); }
public void EmitsFailedWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception) { SyncProgress?emitted = null; SyncManager.ProgressObservable.Subscribe(progress => emitted = progress, (Exception e) => { }); OrchestratorSyncComplete.OnNext(new Error(exception)); emitted.Should().NotBeNull(); emitted.Should().Be(SyncProgress.Failed); }
public void DoesNotEmitSyncedWhenSyncCompletesButAnotherSyncIsQueued(SyncState queuedState) { SyncProgress?emitted = null; Queue.Dequeue().Returns(queuedState); OrchestratorSyncComplete.OnNext(new Success(Pull)); SyncManager.ProgressObservable.Subscribe(progress => emitted = progress); Orchestrator.Received().Start(queuedState); emitted.Should().NotBe(SyncProgress.Synced); }
public void AgainTellsQueueToStartSyncAfterCompletingPreviousPushSync() { Queue.Dequeue().Returns(Pull); SyncManager.PushSync(); Queue.Dequeue().Returns(Sleep); OrchestratorSyncComplete.OnNext(new Success(Push)); Queue.ClearReceivedCalls(); CallMethod(); Queue.Received().Dequeue(); }
public void EmitsSyncedWhenSyncCompletesAndQueueIsEmpty() { SyncProgress?emitted = null; Queue.Dequeue().Returns(Sleep); OrchestratorSyncComplete.OnNext(new Success(Pull)); SyncManager.ProgressObservable.Subscribe(progress => emitted = progress); emitted.Should().NotBeNull(); emitted.Should().Be(SyncProgress.Synced); }
public void AgainTellsQueueToStartSyncAfterCompletingPreviousFullSync() { Queue.StartNextQueuedState(Orchestrator).Returns(Pull); SyncManager.ForceFullSync(); Queue.StartNextQueuedState(Orchestrator).Returns(Sleep); OrchestratorSyncComplete.OnNext(Pull); Queue.ClearReceivedCalls(); CallMethod(); Queue.Received().StartNextQueuedState(Orchestrator); }
public void PerformsThreadSafeClearingOfTheQueue() { var startQueueing = new AutoResetEvent(false); var startClearing = new AutoResetEvent(false); var queueCleared = new AutoResetEvent(false); int iterator = 0; int queued = -1; int cleared = -1; Queue.When(q => q.QueuePullSync()).Do(_ => { startClearing.Set(); Task.Delay(10).Wait(); queued = Interlocked.Increment(ref iterator); }); Queue.When(q => q.Clear()).Do(_ => { cleared = Interlocked.Increment(ref iterator); queueCleared.Set(); }); Task.Run(() => { startQueueing.WaitOne(); SyncManager.ForceFullSync(); }); Task.Run(() => { startClearing.WaitOne(); OrchestratorSyncComplete.OnNext(new Error(new Exception())); }); startQueueing.Set(); queueCleared.WaitOne(); queued.Should().BeLessThan(cleared); }
public void GoesToSleepAfterAnErrorIsReported() { OrchestratorSyncComplete.OnNext(new Error(new Exception())); Orchestrator.Received().Start(Arg.Is(Sleep)); }
public async Task DoesNotQueueUntilOtherCompletedEventReturns() { await ensureMethodIsThreadSafeWith(() => OrchestratorSyncComplete.OnNext(new Success(0))); }
protected override void CallMethod() => OrchestratorSyncComplete.OnNext(new Success(0));
public void UpdatesInternalStateSoItIsNotLockedForFutureSyncsAfterAnErrorIsReported() { OrchestratorSyncComplete.OnNext(new Error(new Exception())); SyncManager.IsRunningSync.Should().BeFalse(); }
public void ClearsTheSyncQueueWhenAnErrorIsReported() { OrchestratorSyncComplete.OnNext(new Error(new Exception())); Queue.Received().Clear(); }
public void FreezesTheSyncManagerWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception) { OrchestratorSyncComplete.OnNext(new Error(exception)); Orchestrator.Received().Freeze(); }
public void ThrowsWhenAnUnsupportedSyncResultIsEmittedByTheOrchestrator() { Action emittingUnsupportedResult = () => OrchestratorSyncComplete.OnNext(new UnsupportedResult()); emittingUnsupportedResult.Should().Throw <ArgumentException>(); }