public void DoesNothingWithInvalidStrings(string invalidId) { ViewModel.Init(invalidId); InteractorFactory .DidNotReceive() .GetCalendarItemWithId(Arg.Any <string>()); }
public async Task DoesNotLogTheUserOutIfPermissionIsDenied() { await setup(hasUnsyncedData : true, userConfirmsSignout : false); ViewModel.SignOut.Execute(); TestScheduler.Start(); InteractorFactory.DidNotReceive().Logout(Arg.Any <LogoutSource>()); }
public async ThreadingTask CannotBeExecutedWhenNoTimeEntryIsRunning() { subject.OnNext(null); TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(50).Ticks); await ViewModel.StopTimeEntryCommand.ExecuteAsync(); await InteractorFactory.DidNotReceive().StopTimeEntry(Arg.Any <DateTimeOffset>()).Execute(); }
public async ThreadingTask DoesNotDeleteTheTimeEntryIfTheUndoIsInitiatedBeforeTheUndoPeriodIsOver() { viewModel.DelayDeleteTimeEntry.Execute(timeEntry); SchedulerProvider.TestScheduler.AdvanceBy(Constants.UndoTime.Ticks / 2); viewModel.CancelDeleteTimeEntry.Execute(); SchedulerProvider.TestScheduler.Start(); InteractorFactory.DidNotReceive().DeleteTimeEntry(Arg.Is(timeEntry.Id)); }
public void DoesNotHardDeletesTheTimeEntryWhenNotCallingFinilizeDelayDeleteTimeEntryIfNeeded() { var batch = new long[] { 1, 2, 3 }; var observableA = viewModel.DelayDeleteTimeEntries.ExecuteWithCompletion(batch); SchedulerProvider.TestScheduler.AdvanceBy(Constants.UndoTime.Ticks / 2); InteractorFactory.DidNotReceive().DeleteMultipleTimeEntries(Arg.Is(batch)).Execute(); }
public void DoesNotCreateAnyTimeEntryWhenUserSelectsTheCancelOption() { DialogService.Select <CalendarItem?>(null, null, 0) .ReturnsForAnyArgs(Observable.Return <CalendarItem?>(null)); ViewModel.OnCalendarEventLongPressed.Inputs.OnNext(calendarEvent); InteractorFactory .DidNotReceive() .CreateTimeEntry(Arg.Any <ITimeEntryPrototype>()); }
public async ThreadingTask DoesNotHardDeletesTheTimeEntryWhenNotCallingFinilizeDelayDeleteTimeEntryIfNeeded() { var timeEntryA = new TimeEntryViewModel(new MockTimeEntry { Id = 1, Duration = 123, TagIds = Array.Empty <long>(), Workspace = new MockWorkspace() }, DurationFormat.Classic); var observableA = viewModel.DelayDeleteTimeEntry.Execute(timeEntryA); SchedulerProvider.TestScheduler.AdvanceBy(Constants.UndoTime.Ticks / 2); InteractorFactory.DidNotReceive().DeleteTimeEntry(Arg.Is(timeEntryA.Id)).Execute(); }
public async Task DoesNotCallCreateIfTheProjectNameIsInvalid() { ViewModel.Prepare("Some name"); ViewModel.Name = ""; await ViewModel.DoneCommand.ExecuteAsync(); await InteractorFactory .DidNotReceive() .CreateProject(Arg.Any <CreateProjectDTO>()) .Execute(); }
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 void DoesNotCallCreateIfTheProjectNameIsInvalid() { ViewModel.Prepare("Some name"); TestScheduler.Start(); ViewModel.Name.Accept(""); TestScheduler.Start(); ViewModel.Save.Execute(); TestScheduler.Start(); InteractorFactory .DidNotReceive() .CreateProject(Arg.Any <CreateProjectDTO>()) .Execute(); }
public async Task ShouldNotTriggerAReportReloadWhenSelectionIsCancelled() { TimeService.CurrentDateTime.Returns(DateTimeOffset.Now); await ViewModel.Initialize(); DialogService.Select(Arg.Any <string>(), Arg.Any <IEnumerable <(string, IThreadSafeWorkspace)> >(), Arg.Any <int>()) .Returns(Observable.Return <IThreadSafeWorkspace>(null)); ViewModel.SelectWorkspace.Execute(); TestScheduler.Start(); InteractorFactory.DidNotReceive().GetProjectSummary( Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>()); }
public async ThreadingTask CannotBeExecutedWhenNoTimeEntryIsRunning() { subject.OnNext(null); TestScheduler.AdvanceBy(TimeSpan.FromMilliseconds(50).Ticks); var observer = TestScheduler.CreateObserver <Unit>(); ViewModel.StopTimeEntry.Execute(TimeEntryStopOrigin.Manual) .Subscribe(observer); TestScheduler.Start(); observer.Messages.Count.Should().Be(1); observer.Messages.Last().Value.Exception.Should().BeEquivalentTo(new RxActionNotEnabledException()); await InteractorFactory.DidNotReceive().StopTimeEntry(Arg.Any <DateTimeOffset>(), Arg.Any <TimeEntryStopOrigin>()).Execute(); }
public async Task DoesNotUseInteractorsWhenTheSarchStringIsEmpty() { var textFieldInfo = TextFieldInfo.Empty(1).ReplaceSpans(new QueryTextSpan()); await Provider.Query(QueryInfo.ParseFieldInfo(textFieldInfo)); InteractorFactory .DidNotReceive() .GetTagsAutocompleteSuggestions(Arg.Any <IList <string> >()); InteractorFactory .DidNotReceive() .GetProjectsAutocompleteSuggestions(Arg.Any <IList <string> >()); InteractorFactory .DidNotReceive() .GetTimeEntriesAutocompleteSuggestions(Arg.Any <IList <string> >()); }
public async Task ShouldNotTriggerAReportReloadWhenTheSameWorkspaceIsSelected() { TimeService.CurrentDateTime.Returns(DateTimeOffset.Now); await ViewModel.Initialize(); var mockWorkspace = new MockWorkspace { Id = WorkspaceId }; View.Select(Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <IThreadSafeWorkspace> > >(), Arg.Any <int>()) .Returns(Observable.Return <IThreadSafeWorkspace>(mockWorkspace)); ViewModel.SelectWorkspace.Execute(); TestScheduler.Start(); InteractorFactory.DidNotReceive().GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>()); }
public async Task ShouldNotTriggerReloadAfterDisappearingAndAppearingImmediately(int numberOfAppearances) { TimeService.CurrentDateTime.Returns(DateTimeOffset.Now); Interactor.Execute() .ReturnsForAnyArgs(Observable.Empty <ProjectSummaryReport>(SchedulerProvider.TestScheduler)); await ViewModel.Initialize(); ViewModel.CalendarViewModel.ViewAppeared(); InteractorFactory.ClearReceivedCalls(); for (int i = 0; i < numberOfAppearances; ++i) { ViewModel.ViewDisappeared(); ViewModel.ViewAppeared(); } TestScheduler.Start(); InteractorFactory .DidNotReceive() .GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>()); }