public void IsRepairRequired_WhenPrintersExist_ReturnsFalse() { _printerHelper.GetPDFCreatorPrinters().Returns(new[] { "PDFCreator" }); var repairPrinter = BuildRepairPrinterAssistant(); Assert.IsFalse(repairPrinter.IsRepairRequired()); }
/// <summary> /// Get the name of the indexed printer of the list /// </summary> /// <param name="index">Printer position in the printer list</param> /// <returns>Name of the printer</returns> public string GetPrinterByIndex(int index) { var printerList = _printerHelper.GetPDFCreatorPrinters(); if (index >= printerList.Count) { throw new ArgumentException("Index must not be greater than the actual number of printers available"); } if (index < 0) { throw new ArgumentException("Index has to be greater or equal to 0"); } return(printerList[index]); }
private void CheckPrinterMappings(PdfCreatorSettings settings) { var printers = _printerHelper.GetPDFCreatorPrinters(); // if there are no printers, something is broken and we need to fix that first if (!printers.Any()) { return; } //Assign DefaultProfile for all installed printers without mapped profile. foreach (var printer in printers) { if (settings.ApplicationSettings.PrinterMappings.All(o => o.PrinterName != printer)) { settings.ApplicationSettings.PrinterMappings.Add(new PrinterMapping(printer, ProfileGuids.DEFAULT_PROFILE_GUID)); } } //Remove uninstalled printers from mapping foreach (var mapping in settings.ApplicationSettings.PrinterMappings.ToArray()) { if (printers.All(o => o != mapping.PrinterName)) { settings.ApplicationSettings.PrinterMappings.Remove(mapping); } } //Check primary printer if ( settings.ApplicationSettings.PrinterMappings.All( o => o.PrinterName != settings.ApplicationSettings.PrimaryPrinter)) { settings.ApplicationSettings.PrimaryPrinter = _printerHelper.GetApplicablePDFCreatorPrinter("PDFCreator", "PDFCreator") ?? ""; } }
public bool IsRepairRequired() { return(!_printerHelper.GetPDFCreatorPrinters().Any()); }