LineTests.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.VisualTests;
  5. public class LineTests
  6. {
  7. [Test]
  8. public void ThicknessHorizontal(
  9. [Values(1, 2, 4, 8)] float thickness)
  10. {
  11. VisualTest.PerformWithDefaultPageSettings(container =>
  12. {
  13. container
  14. .Width(100)
  15. .Column(column =>
  16. {
  17. column.Item().Height(50).Background(Colors.Blue.Lighten4);
  18. column.Item().LineHorizontal(thickness);
  19. column.Item().Height(50).Background(Colors.Green.Lighten4);
  20. });
  21. });
  22. }
  23. [Test]
  24. public void ThicknessVertical(
  25. [Values(1, 2, 4, 8)] float thickness)
  26. {
  27. VisualTest.PerformWithDefaultPageSettings(container =>
  28. {
  29. container
  30. .Height(100)
  31. .Row(row =>
  32. {
  33. row.AutoItem().Width(50).Background(Colors.Blue.Lighten4);
  34. row.AutoItem().LineVertical(thickness);
  35. row.AutoItem().Width(50).Background(Colors.Green.Lighten4);
  36. });
  37. });
  38. }
  39. private static readonly IEnumerable<Color> ColorValues = [Colors.Red.Medium, Colors.Green.Medium, Colors.Blue.Medium];
  40. [Test]
  41. public void Color(
  42. [ValueSource(nameof(ColorValues))] Color color)
  43. {
  44. VisualTest.PerformWithDefaultPageSettings(container =>
  45. {
  46. container
  47. .Width(100)
  48. .LineHorizontal(4)
  49. .LineColor(color);
  50. });
  51. }
  52. private static readonly IEnumerable<Color[]> GradientValues =
  53. [
  54. [Colors.Red.Medium, Colors.Green.Medium],
  55. [Colors.Red.Medium, Colors.Yellow.Medium, Colors.Green.Medium],
  56. [Colors.Blue.Medium, Colors.LightBlue.Medium, Colors.Cyan.Medium, Colors.Teal.Medium, Colors.Green.Medium]
  57. ];
  58. [Test]
  59. public void Gradient(
  60. [ValueSource(nameof(GradientValues))] Color[] colors)
  61. {
  62. VisualTest.PerformWithDefaultPageSettings(container =>
  63. {
  64. container
  65. .Width(400)
  66. .LineHorizontal(16)
  67. .LineGradient(colors);
  68. });
  69. }
  70. private static readonly IEnumerable<float[]> DashPatternCases =
  71. [
  72. [1, 1],
  73. [1, 2],
  74. [2, 1],
  75. [2, 2],
  76. [4, 4],
  77. [8, 8],
  78. [4, 4, 12, 4],
  79. [4, 4, 8, 8, 12, 12],
  80. ];
  81. [Test, TestCaseSource(nameof(DashPatternCases))]
  82. public void DashPattern(float[] dashPattern)
  83. {
  84. VisualTest.PerformWithDefaultPageSettings(container =>
  85. {
  86. container
  87. .Width(400)
  88. .LineHorizontal(4)
  89. .LineDashPattern(dashPattern);
  90. });
  91. }
  92. [Test]
  93. public void Complex()
  94. {
  95. VisualTest.PerformWithDefaultPageSettings(container =>
  96. {
  97. container
  98. .Width(300)
  99. .LineHorizontal(8)
  100. .LineDashPattern([4, 4, 8, 8, 12, 12])
  101. .LineGradient([Colors.Red.Medium, Colors.Orange.Medium, Colors.Yellow.Medium]);
  102. });
  103. }
  104. }