private void UpdatePrinterList() { if (_pdfCreatorPrinters == null) { _pdfCreatorPrinters = new List <string>(); } _pdfCreatorPrinters.Clear(); foreach (var printer in _printerProvider.GetPDFCreatorPrinters()) { _pdfCreatorPrinters.Add(printer); } RaisePropertyChanged(nameof(PdfCreatorPrinters)); }
private List <string> GetUnusedPrinters(IEnumerable <PrinterMapping> loadedPrinterMappings) { var list = loadedPrinterMappings.Select(mapping => mapping.PrinterName).ToList(); var installedPrinters = _printerProvider.GetPDFCreatorPrinters(); var unusedPrinters = new List <string>(); foreach (var printer in installedPrinters) { if (!list.Contains(printer)) { unusedPrinters.Add(printer); } } return(unusedPrinters); }
public void AddPrinterCommand_Execute_PrinterMappingContainsPrinterWithGivenName_DefaultProfileGuidIsAssigned() { var conversionProfiles = new[] { new ConversionProfile { Guid = ProfileGuids.DEFAULT_PROFILE_GUID } }; _settings = new PdfCreatorSettings(null); var newPrinterName = "New printer for testing"; _printerProvider.GetPDFCreatorPrinters().Returns(new[] { newPrinterName }); var printerTabViewModel = BuildViewModel(conversionProfiles); _printerActionAssistant.AddPrinter().Returns <string>(x => newPrinterName); printerTabViewModel.AddPrinterCommand.Execute(null); Assert.AreEqual(1, printerTabViewModel.PrinterMappings.Count, "Added more or less than one printer"); Assert.AreEqual(newPrinterName, printerTabViewModel.PrinterMappings[0].PrinterMapping.PrinterName, "Wrong printername"); Assert.AreEqual(ProfileGuids.DEFAULT_PROFILE_GUID, printerTabViewModel.PrinterMappings[0].PrinterMapping.ProfileGuid, "Did not assign the default profile GUID."); }
private List <string> FindMissingPrinters(IEnumerable <PrinterMapping> printerMappings) { var installedPrinters = _printerProvider.GetPDFCreatorPrinters(); return(printerMappings .Select(pm => pm.PrinterName) .Where(p => !installedPrinters.Contains(p)) .Distinct() .ToList()); }
public void LoadIniSettings_HasNoUnusedPrinters_DeleteUnusedPrintersIsNotCalled() { const string filename = "MyFileName"; SetSuccessfulOpenFileInteraction(filename); _invoker.When(x => x.Invoke(Arg.Any <MessageInteraction>())) .Do(info => info.Arg <MessageInteraction>().Response = MessageResponse.Yes); _settingsHelper.CheckValidSettings(Arg.Any <PdfCreatorSettings>()).Returns(true); _printerProvider.GetPDFCreatorPrinters() .Returns(new List <string>()); // return empty list for installed PDFCreator printers, so there are no unused printers _creatorIniSettingsAssistant.LoadIniSettings(); _iniSettingsLoader.Received().LoadIniSettings(filename); _settingsManager.Received().ApplyAndSaveSettings(Arg.Any <PdfCreatorSettings>()); }