Tests.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.Previewer;
  10. using QuestPDF.ReportSample.Layouts;
  11. namespace QuestPDF.ReportSample
  12. {
  13. public class ReportGeneration
  14. {
  15. private StandardReport Report { get; set; }
  16. [SetUp]
  17. public void SetUp()
  18. {
  19. var model = DataSource.GetReport();
  20. Report = new StandardReport(model);
  21. }
  22. [Test]
  23. public void GenerateAndShowPdf()
  24. {
  25. Report.ShowInPreviewer();
  26. //ImagePlaceholder.Solid = true;
  27. //
  28. // var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
  29. // Report.GeneratePdf(path);
  30. // Process.Start("explorer.exe", path);
  31. }
  32. [Test]
  33. public void GenerateAndShowXps()
  34. {
  35. var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.xps");
  36. Report.GenerateXps(path);
  37. Process.Start("explorer.exe", path);
  38. }
  39. [Test]
  40. public void Profile()
  41. {
  42. ImagePlaceholder.Solid = true;
  43. var container = new DocumentContainer();
  44. Report.Compose(container);
  45. var content = container.Compose();
  46. var pageContext = new PageContext();
  47. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content);
  48. DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content);
  49. }
  50. }
  51. }