Tests.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Threading.Tasks;
  7. using NUnit.Framework;
  8. using QuestPDF.Drawing;
  9. using QuestPDF.Fluent;
  10. using QuestPDF.Infrastructure;
  11. using QuestPDF.ReportSample.Layouts;
  12. namespace QuestPDF.ReportSample
  13. {
  14. public class ReportGeneration
  15. {
  16. private StandardReport Report { get; set; }
  17. [SetUp]
  18. public void SetUp()
  19. {
  20. QuestPDF.Settings.License = LicenseType.Community;
  21. var model = DataSource.GetReport();
  22. Report = new StandardReport(model);
  23. //ImagePlaceholder.Solid = true;
  24. }
  25. [Test]
  26. [Ignore("This test is for manual testing only.")]
  27. public void GeneratePdfAndShow()
  28. {
  29. Report.GeneratePdfAndShow();
  30. }
  31. [Test]
  32. [Ignore("This test is for manual testing only.")]
  33. public void GenerateXpsAndShow()
  34. {
  35. Report.GenerateXpsAndShow();
  36. }
  37. [Test]
  38. public void GeneratePdfForManualVerificationTesting()
  39. {
  40. Report.GeneratePdf("report.pdf");
  41. }
  42. [Test]
  43. [Description("This test is important, as it checks if all IDisposables are properly disposed, and there are no memory leaks.")]
  44. public async Task CheckFinalizersStability()
  45. {
  46. Settings.EnableCaching = true;
  47. Report.GeneratePdf();
  48. Report.GenerateImages(new ImageGenerationSettings { RasterDpi = 72 });
  49. Report.GenerateSvg();
  50. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  51. Report.GenerateXps();
  52. await Task.Delay(1000);
  53. GC.Collect();
  54. GC.WaitForPendingFinalizers();
  55. await Task.Delay(1000);
  56. }
  57. }
  58. }