Tests.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Linq;
  5. using NUnit.Framework;
  6. using QuestPDF.Drawing;
  7. using QuestPDF.Fluent;
  8. using QuestPDF.Infrastructure;
  9. using QuestPDF.ReportSample.Layouts;
  10. namespace QuestPDF.ReportSample
  11. {
  12. public class ReportGeneration
  13. {
  14. private StandardReport Report { get; set; }
  15. [SetUp]
  16. public void SetUp()
  17. {
  18. var model = DataSource.GetReport();
  19. Report = new StandardReport(model);
  20. }
  21. [Test]
  22. public void GenerateAndShow()
  23. {
  24. var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
  25. Report.GeneratePdf(path);
  26. Process.Start("explorer.exe", path);
  27. }
  28. [Test]
  29. public void Profile()
  30. {
  31. var container = new DocumentContainer();
  32. Report.Compose(container);
  33. var content = container.Compose();
  34. var metadata = Report.GetMetadata();
  35. var pageContext = new PageContext();
  36. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
  37. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
  38. }
  39. }
  40. }