public async Task Refresh_RemovesDeletedJobsFromHistory() { var deletedFilePath = "deletedFilePath"; _file.Exists(deletedFilePath).Returns(false); _storedHistoryFullCapacity.First().HistoricFiles.First().Path = deletedFilePath; var deletedHistoricJob1 = _storedHistoryFullCapacity.First(); _storedHistoryFullCapacity.Last().HistoricFiles.First().Path = deletedFilePath; var deletedHistoricJob2 = _storedHistoryFullCapacity.First(); _jobHistoryManager.History = _storedHistoryFullCapacity; await _jobHistoryManager.Refresh(); Assert.IsFalse(_jobHistoryManager.History.Contains(deletedHistoricJob1), "Did not remove deleted file from history"); Assert.IsFalse(_jobHistoryManager.History.Contains(deletedHistoricJob2), "Did not remove deleted file from history"); }
public void Refresh_RemovesDeletedJobsFromHistory() { _jobHistoryManager.Load(); //Adds jobs to history var deletedFile = "deleted"; _job.OutputFiles[0] = deletedFile; _file.Exists(deletedFile).Returns(false); var deletedHistoricJob = new HistoricJob(_job); _jobHistoryManager.History.Add(deletedHistoricJob); _jobHistoryManager.Refresh(); Assert.IsFalse(_jobHistoryManager.History.Contains(deletedHistoricJob), "Did not remove deleted file from history"); }
public HomeViewModel(IInteractionInvoker interactionInvoker, IFileConversionAssistant fileConversionAssistant, ITranslationUpdater translationUpdater, IPrinterHelper printerHelper, ISettingsProvider settingsProvider, IJobHistoryManager jobHistoryManager, IDispatcher dispatcher, ICommandLocator commandLocator) : base(translationUpdater) { _interactionInvoker = interactionInvoker; _fileConversionAssistant = fileConversionAssistant; _printerHelper = printerHelper; _settingsProvider = settingsProvider; _commandLocator = commandLocator; JobHistory = CollectionViewSource.GetDefaultView(jobHistoryManager.History); jobHistoryManager.HistoryChanged += (sender, args) => { dispatcher.BeginInvoke(JobHistory.Refresh); RaisePropertyChanged(nameof(NumberOfHistoricJobs)); }; JobHistory.MoveCurrentTo(null); //unselect first item ConvertFileCommand = new DelegateCommand(o => ConvertFileExecute()); ClearHistoryCommand = new DelegateCommand(o => jobHistoryManager.Clear()); RefreshHistoryCommand = new DelegateCommand(o => jobHistoryManager.Refresh()); RemoveHistoricJobCommand = new DelegateCommand <HistoricJob>(jobHistoryManager.Remove); ToggleHistoryEnabledCommand = new DelegateCommand <HistoricJob>(hj => HistoryEnabled = !HistoryEnabled); DeleteHistoricFilesCommand = commandLocator.CreateMacroCommand() .AddCommand <DeleteHistoricFilesCommand>() .AddCommand(RefreshHistoryCommand) .Build(); StartQuickActionCommand = new DelegateCommand(StartQuickActionCommandExecute); QuickActionOpenList = new List <QuickActionListItemVo> { GetQuickActionItem <QuickActionOpenWithPdfArchitectCommand>(Translation.OpenPDFArchitect), GetQuickActionItem <QuickActionOpenWithDefaultCommand>(Translation.OpenDefaultProgram), GetQuickActionItem <QuickActionOpenExplorerLocationCommand>(Translation.OpenExplorer), GetQuickActionItem <QuickActionPrintWithPdfArchitectCommand>(Translation.PrintWithPDFArchitect), GetQuickActionItem <QuickActionOpenMailClientCommand>(Translation.OpenMailClient) }; }