Esempio n. 1
0
            public void UnsetsTheIsSyncedFlagWhenTheSyncProcessIsNotRunningButThrereIsSomeTimeEntryToPush()
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(true));
                ProgressSubject.OnNext(SyncProgress.Synced);

                ViewModel.IsSynced.Should().BeFalse();
            }
Esempio n. 2
0
            public void SetsTheIsSyncedFlagAfterTheSyncProcessHasFinishedAndThereIsNoTimeEntryToPush()
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(false));
                ProgressSubject.OnNext(SyncProgress.Synced);

                ViewModel.IsSynced.Should().BeTrue();
            }
Esempio n. 3
0
            public void DoesNotEverSetBothIsRunningSyncAndIsSyncedBothToTrue(NonEmptyArray <SyncProgress> statuses)
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(false));
                var syncedObserver  = TestScheduler.CreateObserver <bool>();
                var syncingObserver = TestScheduler.CreateObserver <bool>();
                var viewModel       = CreateViewModel();

                viewModel.IsSynced.Subscribe(syncedObserver);
                viewModel.IsRunningSync.Subscribe(syncingObserver);

                foreach (var state in statuses.Get)
                {
                    syncedObserver.Messages.Clear();
                    syncingObserver.Messages.Clear();

                    ProgressSubject.OnNext(state);
                    TestScheduler.Start();
                    TestScheduler.Stop();

                    var isSynced      = syncedObserver.SingleEmittedValue();
                    var isRunningSync = syncingObserver.SingleEmittedValue();

                    (isRunningSync && isSynced).Should().BeFalse();
                }
            }
Esempio n. 4
0
 public void SetsIsRunningSyncCorrectly(NonEmptyArray <SyncProgress> statuses)
 {
     foreach (var state in statuses.Get)
     {
         ProgressSubject.OnNext(state);
         ViewModel.IsRunningSync.Should().Be(state == SyncProgress.Syncing);
     }
 }
Esempio n. 5
0
 public Form1()
 {
     InitializeComponent();
     slowWorker = new ProgressSubject();
     sbObserver = new SpinBoxObserver(slowWorker);
     pbObserver = new ProgressBarObserver(slowWorker);
     tbObserver = new TrackBarObserver(slowWorker);
 }
Esempio n. 6
0
 public TogglDataSourceTest()
 {
     SyncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
     DataSource = new TogglDataSource(
         Database,
         TimeService,
         AnalyticsService);
 }
            public async Task ChecksIfThereAreUnsyncedDataWhenTheSyncProcessFinishes()
            {
                ProgressSubject.OnNext(SyncProgress.Synced);

                await ViewModel.TryLogout();

                await DataSource.Received().HasUnsyncedData();
            }
Esempio n. 8
0
 public void DoesNotEverSetBothIsRunningSyncAndIsSyncedBothToTrue(NonEmptyArray <SyncProgress> statuses)
 {
     foreach (var state in statuses.Get)
     {
         ProgressSubject.OnNext(state);
         (ViewModel.IsRunningSync && ViewModel.IsSynced).Should().BeFalse();
     }
 }
Esempio n. 9
0
            public void UnsetsTheIsSyncedFlagWhenThereIsNothingToPushButTheSyncProcessStartsAgain()
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(false));
                ProgressSubject.OnNext(SyncProgress.Synced);
                ProgressSubject.OnNext(SyncProgress.Syncing);

                ViewModel.IsSynced.Should().BeFalse();
            }
Esempio n. 10
0
            protected override void AdditionalSetup()
            {
                base.AdditionalSetup();

                var syncManager = Substitute.For <ISyncManager>();

                syncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
                DataSource.SyncManager.Returns(syncManager);
            }
            public async Task ShowsConfirmationDialogWhenThereIsSomethingToPushButSyncIsNotRunning()
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(true));
                ProgressSubject.OnNext(SyncProgress.Syncing);

                await ViewModel.TryLogout();

                await DialogService.ReceivedWithAnyArgs().Confirm("", "", "", "");
            }
Esempio n. 12
0
 public void DoesNotSetTheIsLoggingOutFlagIfTheLogoutCommandIsNotExecuted(
     NonEmptyArray <SyncProgress> statuses)
 {
     foreach (var state in statuses.Get)
     {
         ProgressSubject.OnNext(state);
         ViewModel.IsLoggingOut.Should().BeFalse();
     }
 }
Esempio n. 13
0
            public async ThreadingTask SetsTheUnauthorizedAccessFlag()
            {
                var exception = new UnauthorizedException(request, response);

                ApiErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);

                ProgressSubject.OnError(exception);

                ApiErrorHandlingService.Received().TryHandleUnauthorizedError(Arg.Is(exception));
            }
Esempio n. 14
0
            public async Task ShowsConfirmationDialogWhenThereIsNothingToPushButSyncIsRunning()
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(false));
                ProgressSubject.OnNext(SyncProgress.Syncing);

                TestScheduler.Start();
                ViewModel.TryLogout.Execute();

                await DialogService.ReceivedWithAnyArgs().Confirm("", "", "", "");
            }
Esempio n. 15
0
            public void DoesNotThrowForAnyExceptionWhichCanBeThrownByTheProgressObservable(Exception exception)
            {
                ApiErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);
                ApiErrorHandlingService.TryHandleDeprecationError(Arg.Any <ClientDeprecatedException>()).Returns(true);
                ApiErrorHandlingService.TryHandleDeprecationError(Arg.Any <ApiDeprecatedException>()).Returns(true);

                Action processingError = () => ProgressSubject.OnError(exception);

                processingError.Should().NotThrow();
            }
Esempio n. 16
0
            public void SetsTheOutdatedApiVersionFlag()
            {
                var exception = new ApiDeprecatedException(request, response);

                ApiErrorHandlingService.TryHandleDeprecationError(Arg.Any <ApiDeprecatedException>()).Returns(true);

                ProgressSubject.OnError(exception);

                ApiErrorHandlingService.Received().TryHandleDeprecationError(Arg.Is(exception));
                ApiErrorHandlingService.DidNotReceive().TryHandleUnauthorizedError(Arg.Is(exception));
            }
Esempio n. 17
0
            public void SetsTheIsRunningSyncAndIsSyncedFlagsToFalseAfterTheIsLoggingInFlagIsSetAndDoesNotSetThemToTrueNoMatterWhatStatusesAreObserved(NonEmptyArray <SyncProgress> statuses)
            {
                DataSource.Logout().Returns(Observable.Never <Unit>());

                ViewModel.LogoutCommand.ExecuteAsync();

                foreach (var state in statuses.Get)
                {
                    ProgressSubject.OnNext(state);
                    ViewModel.IsRunningSync.Should().BeFalse();
                    ViewModel.IsSynced.Should().BeFalse();
                }
            }
Esempio n. 18
0
            public void DoesNotUnsetTheIsLoggingOutFlagAfterItIsSetNoMatterWhatStatusesAreObserved(
                NonEmptyArray <SyncProgress> statuses)
            {
                DataSource.Logout().Returns(Observable.Never <Unit>());

                ViewModel.LogoutCommand.ExecuteAsync();

                foreach (var state in statuses.Get)
                {
                    ProgressSubject.OnNext(state);
                    ViewModel.IsLoggingOut.Should().BeTrue();
                }
            }
Esempio n. 19
0
            public void SetsIsSyncedCorrectly(NonEmptyArray <SyncProgress> statuses)
            {
                foreach (var state in statuses.Get)
                {
                    if (state == SyncProgress.Unknown)
                    {
                        continue;
                    }

                    ProgressSubject.OnNext(state);
                    ViewModel.IsSynced.Should().Be(state == SyncProgress.Synced);
                }
            }
            protected override void AdditionalSetup()
            {
                base.AdditionalSetup();

                var syncManager = Substitute.For <ISyncManager>();

                syncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
                DataSource.SyncManager.Returns(syncManager);

                RemoteConfigService
                .RatingViewConfiguration
                .Returns(Observable.Never <RatingViewConfiguration>());
            }
Esempio n. 21
0
            public async Task DoesNotProceedWithLogoutWhenUserClicksCancelButtonInTheDialog()
            {
                ProgressSubject.OnNext(SyncProgress.Syncing);
                DialogService.Confirm(
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>()).Returns(Observable.Return(false));

                TestScheduler.Start();
                ViewModel.TryLogout.Execute();

                InteractorFactory.DidNotReceive().Logout(Arg.Any <LogoutSource>());
                await NavigationService.DidNotReceive().Navigate <LoginViewModel>();
            }
            public async Task ProceedsWithLogoutWhenUserClicksSignOutButtonInTheDialog()
            {
                ProgressSubject.OnNext(SyncProgress.Syncing);
                DialogService.Confirm(
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>()).Returns(Observable.Return(true));

                await ViewModel.TryLogout();

                await DataSource.Received().Logout();

                await NavigationService.Received().Navigate <LoginViewModel>();
            }
Esempio n. 23
0
            public async Task ProceedsWithLogoutWhenUserClicksSignOutButtonInTheDialog()
            {
                ProgressSubject.OnNext(SyncProgress.Syncing);
                DialogService.Confirm(
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>()).Returns(Observable.Return(true));

                TestScheduler.Start();
                ViewModel.TryLogout.Execute();

                await InteractorFactory.Received().Logout(LogoutSource.Settings).Execute();

                await NavigationService.Received().Navigate <LoginViewModel>();
            }
Esempio n. 24
0
            public void UnsubscribesFromTheBackgroundServiceObservableWhenExceptionIsCaught()
            {
                var subject = new Subject <TimeSpan>();

                BackgroundService.AppResumedFromBackground.Returns(subject.AsObservable());
                DataSource.StartSyncing();
                SyncManager.ClearReceivedCalls();
                var exception = new UnauthorizedException(request, response);

                ApiErrorHandlingService.TryHandleUnauthorizedError(Arg.Any <UnauthorizedException>()).Returns(true);

                ProgressSubject.OnError(exception);
                subject.OnNext(MinimumTimeInBackgroundForFullSync + TimeSpan.FromSeconds(1));

                SyncManager.DidNotReceive().ForceFullSync();
            }
Esempio n. 25
0
            public async Task DoesNotProceedWithLogoutWhenUserClicksCancelButtonInTheDialog()
            {
                ProgressSubject.OnNext(SyncProgress.Syncing);
                DialogService.Confirm(
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>()).Returns(Observable.Return(false));

                await ViewModel.LogoutCommand.ExecuteAsync();

                ViewModel.IsLoggingOut.Should().BeFalse();
                await DataSource.DidNotReceive().Logout();

                await NavigationService.DidNotReceive().Navigate <LoginViewModel>();
            }
Esempio n. 26
0
            public async Task ProceedsWithLogoutWhenUserClicksSignOutButtonInTheDialog()
            {
                ProgressSubject.OnNext(SyncProgress.Syncing);
                DialogService.Confirm(
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>(),
                    Arg.Any <string>()).Returns(true);

                await ViewModel.LogoutCommand.ExecuteAsync();

                ViewModel.IsLoggingOut.Should().BeTrue();
                await DataSource.Received().Logout();

                await NavigationService.Received().Navigate <OnboardingViewModel>();
            }
            public void EmitTheAppropriateIsRunningSyncValues(NonEmptyArray <SyncProgress> statuses)
            {
                DataSource.HasUnsyncedData().Returns(Observable.Return(false));
                var observer  = TestScheduler.CreateObserver <bool>();
                var viewModel = CreateViewModel();

                viewModel.IsRunningSync.Subscribe(observer);

                foreach (var state in statuses.Get)
                {
                    observer.Messages.Clear();

                    ProgressSubject.OnNext(state);

                    var isRunningSync = observer.Messages.Single().Value.Value;
                    isRunningSync.Should().Be(state == SyncProgress.Syncing);
                }
            }
            public void EmitTheAppropriateIsSyncedValues(NonEmptyArray <SyncProgress> statuses)
            {
                var observer  = TestScheduler.CreateObserver <bool>();
                var viewModel = CreateViewModel();

                viewModel.IsSynced.Subscribe(observer);

                foreach (var state in statuses.Get)
                {
                    if (state == SyncProgress.Unknown)
                    {
                        continue;
                    }

                    observer.Messages.Clear();

                    ProgressSubject.OnNext(state);

                    var isSynced = observer.Messages.Single().Value.Value;
                    isSynced.Should().Be(state == SyncProgress.Synced);
                }
            }
Esempio n. 29
0
            public void ChecksIfThereAreUnsyncedDataWhenTheSyncProcessFinishes()
            {
                ProgressSubject.OnNext(SyncProgress.Synced);

                DataSource.Received().HasUnsyncedData();
            }
Esempio n. 30
0
 public ProgressBarObserver(ProgressSubject subject)
     : base(subject)
 {
 }
Esempio n. 31
0
 public TrackBarObserver(ProgressSubject subject)
     : base(subject)
 {
 }
Esempio n. 32
0
 private void doNotShowConfirmationDialog()
 {
     DataSource.HasUnsyncedData().Returns(Observable.Return(false));
     ProgressSubject.OnNext(SyncProgress.Synced);
 }
Esempio n. 33
0
 public ProgressObserver(ProgressSubject subject)
 {
     this.subject = subject;
     EventHandler<ProgressEventArgs> handler = new EventHandler<ProgressEventArgs>(ProgressHandlerMethod);
     subject.ProgressEvent += handler;
 }
Esempio n. 34
0
 public SpinBoxObserver(ProgressSubject subject)
     : base(subject)
 {
 }
Esempio n. 35
0
            public void ThrowsForDifferentException(Exception exception)
            {
                Action handling = () => ProgressSubject.OnError(exception);

                handling.Should().Throw <ArgumentException>();
            }