StyledBoxTests.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using QuestPDF.ConformanceTests.TestEngine;
  2. using QuestPDF.Drawing;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.ConformanceTests;
  7. internal class StyledBoxTests : ConformanceTestBase
  8. {
  9. protected override Document GetDocumentUnderTest()
  10. {
  11. return Document
  12. .Create(document =>
  13. {
  14. document.Page(page =>
  15. {
  16. page.Margin(60);
  17. page.Content()
  18. .PaddingVertical(30)
  19. .SemanticSection()
  20. .Column(column =>
  21. {
  22. column.Spacing(30);
  23. column.Item()
  24. .SemanticHeader1()
  25. .Text("Conformance Test: Styled Boxes")
  26. .FontSize(36)
  27. .Bold()
  28. .FontColor(Colors.Blue.Darken2);
  29. column.Item()
  30. .Background(Colors.Blue.Lighten4)
  31. .Padding(20)
  32. .Text("Background only")
  33. .FontSize(16);
  34. column.Item()
  35. .Border(2, Colors.Blue.Darken2)
  36. .Padding(20)
  37. .Text("Border only")
  38. .FontSize(16);
  39. column.Item()
  40. .Background(Colors.White)
  41. .Shadow(new BoxShadowStyle
  42. {
  43. OffsetX = 5,
  44. OffsetY = 5,
  45. Blur = 10,
  46. Spread = 5,
  47. Color = Colors.Grey.Medium
  48. })
  49. .Padding(20)
  50. .Text("Simple shadow")
  51. .FontSize(16);
  52. column.Item()
  53. .Border(1, Colors.Purple.Lighten4)
  54. .Background(Colors.Purple.Lighten5)
  55. .CornerRadius(15)
  56. .Padding(20)
  57. .Text("Rounded corners")
  58. .FontSize(16);
  59. });
  60. });
  61. });
  62. }
  63. protected override SemanticTreeNode? GetExpectedSemanticTree()
  64. {
  65. return ExpectedSemanticTree.DocumentRoot(root =>
  66. {
  67. root.Child("Sect", sect =>
  68. {
  69. sect.Child("H1", h1 => h1.Alt("Conformance Test: Styled Boxes"));
  70. foreach (var i in Enumerable.Range(1, 4))
  71. sect.Child("P");
  72. });
  73. });
  74. }
  75. }