// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var dllDirectory    = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var targetDirectory = Path.Combine(dllDirectory, "PhantomJs", "pdf-out");

            if (!Directory.Exists(targetDirectory))
            {
                Directory.CreateDirectory(targetDirectory);
            }

            var htmlToPdfConverter = app.ApplicationServices.GetService <IHtmlToPdfConverter>();
            var options            = app.ApplicationServices.GetService <HtmlToPdfConverterOptions>();
            var testRunner         = new TestCaseRunner();

            app.Run(async(context) =>
            {
                var results = testRunner.RunAll(htmlToPdfConverter, targetDirectory);
                var json    = JsonSerializer.Serialize(results);
                await context.Response.WriteAsync(json);
            });
        }
Example #2
0
        public static IEnumerable <TestCaseResult> RunTestCases()
        {
            var htmlToPdfConverter = CreateHtmlToPdfConverter();
            var currentDirectory   = Directory.GetCurrentDirectory();
            var targetDirectory    = Path.Combine(currentDirectory, "PhantomJs", "pdf-out");

            if (!Directory.Exists(targetDirectory))
            {
                Directory.CreateDirectory(targetDirectory);
            }

            var testRunner = new TestCaseRunner();

            return(testRunner.RunAll(htmlToPdfConverter, targetDirectory));
        }