Example #1
0
        private static void Main(string[] args)
        {
            var wrapper = new PDFtoPrinterPrinter();

            wrapper
            .Print(new PrintingOptions("Microsoft Print to PDF", "somefile.pdf"))
            .Wait();
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
Example #5
0
        public void WhenCallDefaultConstructor_ThenCreateInstance()
        {
            var wrapper = new PDFtoPrinterPrinter();

            Assert.IsNotNull(wrapper);
        }
Example #6
0
        public void WhenMaxCuncurrencyValid_ThenCreateInstance(int maxCuncurrency)
        {
            var wrapper = new PDFtoPrinterPrinter(maxCuncurrency);

            Assert.IsNotNull(wrapper);
        }