Tests.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. QuestPDF.Settings.License = LicenseType.Community;
  19. var model = DataSource.GetReport();
  20. Report = new StandardReport(model);
  21. ImagePlaceholder.Solid = true;
  22. }
  23. [Test]
  24. public void GeneratePdfAndShow()
  25. {
  26. //Settings.EnableDebugging = true;
  27. Report.GeneratePdfAndShow();
  28. return;
  29. var times = Enumerable.Range(0, 1).Select(_ => MeasureTime()).ToList();
  30. Console.WriteLine(string.Join(",", times));
  31. Console.WriteLine(times.Sum());
  32. long MeasureTime()
  33. {
  34. var sw = new Stopwatch();
  35. sw.Start();
  36. Report.GeneratePdf();
  37. sw.Stop();
  38. return sw.ElapsedMilliseconds;
  39. }
  40. }
  41. [Test]
  42. public void GenerateXpsAndShow()
  43. {
  44. Report.GenerateXpsAndShow();
  45. }
  46. }
  47. }