private static void Main(string[] args) { var wrapper = new PDFtoPrinterPrinter(); wrapper .Print(new PrintingOptions("Microsoft Print to PDF", "somefile.pdf")) .Wait(); }
public async Task WhenProcessNotCompleted_ThenKill() { var process = new Mock <IProcess>(); process.Setup(x => x.WaitForExitAsync(TimeSpan.FromMinutes(1))) .ReturnsAsync(false); var wrapper = new PDFtoPrinterPrinter( CreateProcessFactory(process.Object)); await wrapper.Print(new PrintingOptions(PrinterName, FilePath)); process.Verify(x => x.Start(), Times.Once); process.Verify(x => x.Kill(), Times.Once); }
public async Task WhenProcessCompleted_ThenDoNotKill() { var process = new Mock <IProcess>(); var timeout = TimeSpan.FromMinutes(2); process.Setup(x => x.WaitForExitAsync(timeout)) .ReturnsAsync(true); var wrapper = new PDFtoPrinterPrinter( CreateProcessFactory(process.Object)); await wrapper.Print(FilePath, PrinterName, timeout); process.Verify(x => x.Start(), Times.Once); process.Verify(x => x.Kill(), Times.Never); }
public static void PrintPDFLocal(string filePath) { PrinterSettings settings = new PrinterSettings(); string printerName = "Microsoft Print to PDF"; if (!String.IsNullOrEmpty(settings.PrinterName)) { printerName = settings.PrinterName; } var printer = new PDFtoPrinterPrinter(); printer.Print(new PrintingOptions(printerName, filePath)); }
public void WhenCallDefaultConstructor_ThenCreateInstance() { var wrapper = new PDFtoPrinterPrinter(); Assert.IsNotNull(wrapper); }
public void WhenMaxCuncurrencyValid_ThenCreateInstance(int maxCuncurrency) { var wrapper = new PDFtoPrinterPrinter(maxCuncurrency); Assert.IsNotNull(wrapper); }