Files
QuestPDF/QuestPDF.ReportSample/Tests.cs
T

56 lines
1.6 KiB
C#
Raw Normal View History

2021-03-21 17:43:46 +01:00
using System;
2021-01-16 01:31:39 +01:00
using System.Diagnostics;
using System.IO;
using System.Linq;
using NUnit.Framework;
2021-09-02 21:48:20 +02:00
using QuestPDF.Drawing;
2021-01-16 01:31:39 +01:00
using QuestPDF.Fluent;
2021-09-06 21:43:12 +02:00
using QuestPDF.Infrastructure;
2021-01-16 01:31:39 +01:00
using QuestPDF.ReportSample.Layouts;
namespace QuestPDF.ReportSample
{
public class ReportGeneration
{
2021-09-06 21:43:12 +02:00
private StandardReport Report { get; set; }
[SetUp]
public void SetUp()
{
var model = DataSource.GetReport();
Report = new StandardReport(model);
}
2021-01-16 01:31:39 +01:00
[Test]
2021-11-19 00:50:38 +01:00
public void GenerateAndShowPdf()
2021-01-16 01:31:39 +01:00
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
2021-09-06 21:43:12 +02:00
Report.GeneratePdf(path);
2021-11-19 00:50:38 +01:00
Process.Start("explorer.exe", path);
}
[Test]
public void GenerateAndShowXps()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.xps");
Report.GenerateXps(path);
2021-01-16 01:31:39 +01:00
Process.Start("explorer.exe", path);
}
2021-09-06 21:43:12 +02:00
2021-01-16 01:31:39 +01:00
[Test]
2021-09-06 21:43:12 +02:00
public void Profile()
2021-01-16 01:31:39 +01:00
{
2021-11-07 16:19:54 +01:00
ImagePlaceholder.Solid = true;
2021-09-06 21:43:12 +02:00
var container = new DocumentContainer();
Report.Compose(container);
var content = container.Compose();
2021-09-06 21:43:12 +02:00
var metadata = Report.GetMetadata();
var pageContext = new PageContext();
2021-01-16 01:31:39 +01:00
2021-09-06 21:43:12 +02:00
DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
2021-01-16 01:31:39 +01:00
}
}
}