public void NoJavascriptDelay_ReturnsError()
        {
            HtmlToPdfRunner runner = new HtmlToPdfRunner(HtmlToPdfRunner.HtmlToPdfExe);

            string html = @"<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
   Test Page
  </body>
</html>";

            using (TempHtmlFile htmlFile = new TempHtmlFile(html))
            {
                using (TempPdfFile pdfFile = new TempPdfFile(this.TestContext))
                {
                    string[] commandLine = new[]
                    {
                        "--log-level Error",
                        "--javascript-delay",
                        $"\"{htmlFile.FilePath}\"",
                        $"\"{pdfFile.FilePath}\"",
                    };

                    HtmlToPdfRunResult result = runner.Run(string.Join(" ", commandLine));
                    Assert.AreEqual(1, result.ExitCode);

                    string expectedOutput = HelpTextGenerator.GenerateParserError(
                        "Option 'javascript-delay' is defined with a bad format.");
                    Assert.IsTrue(string.IsNullOrEmpty(result.StandardOutput), result.StandardOutput);
                    Assert.IsTrue(result.StandardError.Trim().StartsWith(expectedOutput.Trim()), result.StandardError);
                }
            }
        }
Exemplo n.º 2
0
        public void HelpArgument_DisplaysHelpText(string commandLine)
        {
            string expectedOutput = HelpTextGenerator.Generate();

            HtmlToPdfRunner runner = new HtmlToPdfRunner(HtmlToPdfRunner.HtmlToPdfExe);

            HtmlToPdfRunResult result = runner.Run(commandLine);

            Assert.AreEqual(1, result.ExitCode, result.Output);
            Assert.IsTrue(string.IsNullOrEmpty(result.StandardOutput), result.StandardOutput);
            StringAssertWithDiff.AreEqual(expectedOutput.Trim(), result.StandardError.Trim());
        }
Exemplo n.º 3
0
        public void VersionArgument_DisplaysVersionInformation(string commandLine)
        {
            string expectedOutput = HelpTextGenerator.GetVersionInformation();

            HtmlToPdfRunner runner = new HtmlToPdfRunner(HtmlToPdfRunner.HtmlToPdfExe);

            HtmlToPdfRunResult result = runner.Run(commandLine);

            Assert.AreEqual(1, result.ExitCode, result.Output);
            Assert.IsTrue(string.IsNullOrEmpty(result.StandardOutput), result.StandardOutput);
            Assert.IsTrue(result.StandardError.Trim().StartsWith(expectedOutput.Trim()), result.StandardError);
        }