Tests.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. public void StabilityTesting()
  44. {
  45. Parallel.ForEach(Enumerable.Range(0, 1000), i =>
  46. {
  47. var model = DataSource.GetReport();
  48. var report = new StandardReport(model);
  49. report.GeneratePdf();
  50. });
  51. }
  52. [Test]
  53. public async Task CheckFinalizersStability()
  54. {
  55. Settings.EnableCaching = true;
  56. Report.GeneratePdf();
  57. Report.GenerateImages();
  58. Report.GenerateSvg();
  59. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  60. Report.GenerateXps();
  61. await Task.Delay(1000);
  62. GC.Collect();
  63. GC.WaitForPendingFinalizers();
  64. await Task.Delay(1000);
  65. }
  66. }
  67. }