Tests.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 GenerateAndShowPdf()
  23. {
  24. //ImagePlaceholder.Solid = true;
  25. var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
  26. Report.GeneratePdf(path);
  27. Process.Start("explorer.exe", path);
  28. }
  29. [Test]
  30. public void GenerateAndShowXps()
  31. {
  32. var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.xps");
  33. Report.GenerateXps(path);
  34. Process.Start("explorer.exe", path);
  35. }
  36. [Test]
  37. public void Profile()
  38. {
  39. ImagePlaceholder.Solid = true;
  40. var container = new DocumentContainer();
  41. Report.Compose(container);
  42. var content = container.Compose();
  43. var metadata = Report.GetMetadata();
  44. var pageContext = new PageContext();
  45. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
  46. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null);
  47. }
  48. }
  49. }