public void UnsetsTheIsSyncedFlagWhenTheSyncProcessIsNotRunningButThrereIsSomeTimeEntryToPush() { DataSource.HasUnsyncedData().Returns(Observable.Return(true)); ProgressSubject.OnNext(SyncProgress.Synced); ViewModel.IsSynced.Should().BeFalse(); }
public void SetsTheIsSyncedFlagAfterTheSyncProcessHasFinishedAndThereIsNoTimeEntryToPush() { DataSource.HasUnsyncedData().Returns(Observable.Return(false)); ProgressSubject.OnNext(SyncProgress.Synced); ViewModel.IsSynced.Should().BeTrue(); }
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(); } }
public void SetsIsRunningSyncCorrectly(NonEmptyArray <SyncProgress> statuses) { foreach (var state in statuses.Get) { ProgressSubject.OnNext(state); ViewModel.IsRunningSync.Should().Be(state == SyncProgress.Syncing); } }
public Form1() { InitializeComponent(); slowWorker = new ProgressSubject(); sbObserver = new SpinBoxObserver(slowWorker); pbObserver = new ProgressBarObserver(slowWorker); tbObserver = new TrackBarObserver(slowWorker); }
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(); }
public void DoesNotEverSetBothIsRunningSyncAndIsSyncedBothToTrue(NonEmptyArray <SyncProgress> statuses) { foreach (var state in statuses.Get) { ProgressSubject.OnNext(state); (ViewModel.IsRunningSync && ViewModel.IsSynced).Should().BeFalse(); } }
public void UnsetsTheIsSyncedFlagWhenThereIsNothingToPushButTheSyncProcessStartsAgain() { DataSource.HasUnsyncedData().Returns(Observable.Return(false)); ProgressSubject.OnNext(SyncProgress.Synced); ProgressSubject.OnNext(SyncProgress.Syncing); ViewModel.IsSynced.Should().BeFalse(); }
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("", "", "", ""); }
public void DoesNotSetTheIsLoggingOutFlagIfTheLogoutCommandIsNotExecuted( NonEmptyArray <SyncProgress> statuses) { foreach (var state in statuses.Get) { ProgressSubject.OnNext(state); ViewModel.IsLoggingOut.Should().BeFalse(); } }
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)); }
public async Task ShowsConfirmationDialogWhenThereIsNothingToPushButSyncIsRunning() { DataSource.HasUnsyncedData().Returns(Observable.Return(false)); ProgressSubject.OnNext(SyncProgress.Syncing); TestScheduler.Start(); ViewModel.TryLogout.Execute(); await DialogService.ReceivedWithAnyArgs().Confirm("", "", "", ""); }
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(); }
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)); }
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(); } }
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(); } }
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>()); }
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>(); }
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>(); }
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(); }
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>(); }
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); } }
public void ChecksIfThereAreUnsyncedDataWhenTheSyncProcessFinishes() { ProgressSubject.OnNext(SyncProgress.Synced); DataSource.Received().HasUnsyncedData(); }
public ProgressBarObserver(ProgressSubject subject) : base(subject) { }
public TrackBarObserver(ProgressSubject subject) : base(subject) { }
private void doNotShowConfirmationDialog() { DataSource.HasUnsyncedData().Returns(Observable.Return(false)); ProgressSubject.OnNext(SyncProgress.Synced); }
public ProgressObserver(ProgressSubject subject) { this.subject = subject; EventHandler<ProgressEventArgs> handler = new EventHandler<ProgressEventArgs>(ProgressHandlerMethod); subject.ProgressEvent += handler; }
public SpinBoxObserver(ProgressSubject subject) : base(subject) { }
public void ThrowsForDifferentException(Exception exception) { Action handling = () => ProgressSubject.OnError(exception); handling.Should().Throw <ArgumentException>(); }