public async Task TracksIfSyncSucceeds(PushNotificationSyncSourceState sourceState)
            {
                SyncManager.ForceFullSync().Returns(Observable.Return(SyncState.Sleep));
                var interactor = CreateSyncInteractor(sourceState);

                await interactor.Execute().SingleAsync();

                AnalyticsService.PushNotificationSyncStarted.Received().Track(sourceState.ToString());
                AnalyticsService.PushNotificationSyncFinished.Received().Track(sourceState.ToString());
                AnalyticsService.PushNotificationSyncFailed.DidNotReceive().Track(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
            }
            public async Task TracksIfSyncFails(PushNotificationSyncSourceState sourceState)
            {
                var exception = new Exception();

                SyncManager.ForceFullSync().Returns(Observable.Throw <SyncState>(exception));
                var interactor = CreateSyncInteractor(sourceState);

                await interactor.Execute().SingleAsync();

                AnalyticsService.PushNotificationSyncStarted.Received().Track(sourceState.ToString());
                AnalyticsService.PushNotificationSyncFinished.Received().Track(sourceState.ToString());
                AnalyticsService.PushNotificationSyncFailed.Received().Track(sourceState.ToString(), exception.GetType().FullName, exception.Message, exception.StackTrace);
            }
示例#3
0
        public IObservable <SyncOutcome> Execute()
        {
            analyticsService.PushNotificationSyncStarted.Track(sourceState.ToString());

            var syncAction = sourceState == PushNotificationSyncSourceState.Foreground
                ? syncManager.PullTimeEntries()
                             .LastAsync()
                             .ThenExecute(syncManager.ForceFullSync)
                : syncManager.PullTimeEntries();

            return(syncAction.LastAsync()
                   .Select(_ => SyncOutcome.NewData)
                   .Catch((Exception error) => syncFailed(error))
                   .Do(outcome =>
            {
                analyticsService.PushNotificationSyncFinished.Track(sourceState.ToString());
            }));
        }