Exemple #1
0
        public void Can_print_the_pdf_from_a_view()
        {
            var testLink = _selenium.FindElement(By.LinkText("Test View"));
            var pdfHref  = testLink.GetAttribute("href");

            using (var wc = new WebClient())
            {
                var pdfResult = wc.DownloadData(new Uri(pdfHref));
                var pdfTester = new PdfTester(_output);
                pdfTester.LoadPdf(pdfResult);
                pdfTester.PdfIsValid.Should().Be.True();
                pdfTester.PdfContains("My MVC Application").Should().Be.True();
            }
        }
Exemple #2
0
        public void Can_print_pdf_from_page_with_content_from_ajax_request()
        {
            var          testLink = _selenium.FindElement(By.LinkText("Ajax Test"));
            var          pdfHref  = testLink.GetAttribute("href");
            const string content  = "Hi there, this is content from a Ajax call.";

            using (var wc = new WebClient())
            {
                var pdfResult = wc.DownloadData(new Uri(pdfHref));
                var pdfTester = new PdfTester(_output);
                pdfTester.LoadPdf(pdfResult);
                pdfTester.PdfIsValid.Should().Be.True();
                pdfTester.PdfContains(content).Should().Be.True();
            }
        }
Exemple #3
0
        public void Can_print_pdf_from_page_with_external_css_file()
        {
            var          testLink = _selenium.FindElement(By.LinkText("External CSS Test"));
            var          pdfHref  = testLink.GetAttribute("href");
            const string content  = "Hi guys, this content shows up thanks to css file.";

            using (var wc = new WebClient())
            {
                var pdfResult = wc.DownloadData(new Uri(pdfHref));
                var pdfTester = new PdfTester(_output);
                pdfTester.LoadPdf(pdfResult);
                pdfTester.PdfIsValid.Should().Be.True();
                pdfTester.PdfContains(content).Should().Be.True();
            }
        }
Exemple #4
0
        public void Can_print_the_pdf_from_a_partial_view_with_a_model()
        {
            var          testLink = _selenium.FindElement(By.LinkText("Test PartialViewAsPdf with a model"));
            var          pdfHref  = testLink.GetAttribute("href");
            const string content  = "This is a test with a partial view";

            using (var wc = new WebClient())
            {
                var pdfResult = wc.DownloadData(new Uri(pdfHref));
                var pdfTester = new PdfTester(_output);
                pdfTester.LoadPdf(pdfResult);
                pdfTester.PdfIsValid.Should().Be.True();
                pdfTester.PdfContains(content).Should().Be.True();
            }
        }