TableTests.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. namespace QuestPDF.LayoutTests;
  2. public class TableTests
  3. {
  4. [Test]
  5. public void RowSpan_CornerCase1()
  6. {
  7. LayoutTest
  8. .HavingSpaceOfSize(200, 400)
  9. .ForContent(content =>
  10. {
  11. content
  12. .Table(table =>
  13. {
  14. table.ColumnsDefinition(columns =>
  15. {
  16. columns.RelativeColumn();
  17. });
  18. table.Cell()
  19. .RowSpan(2)
  20. .Mock("a")
  21. .SolidBlock(100, 100);
  22. table.Cell()
  23. .Mock("b")
  24. .SolidBlock(100, 350);
  25. });
  26. })
  27. .ExpectDrawResult(document =>
  28. {
  29. document
  30. .Page()
  31. .RequiredAreaSize(200, 100)
  32. .Content(page =>
  33. {
  34. page.Mock("a").Position(0, 0).Size(200, 100);
  35. });
  36. document
  37. .Page()
  38. .RequiredAreaSize(200, 350)
  39. .Content(page =>
  40. {
  41. page.Mock("b").Position(0, 0).Size(200, 350);
  42. });
  43. });
  44. }
  45. [Test]
  46. public void RowSpan_CornerCase2()
  47. {
  48. LayoutTest
  49. .HavingSpaceOfSize(200, 400)
  50. .ForContent(content =>
  51. {
  52. content
  53. .Table(table =>
  54. {
  55. table.ColumnsDefinition(columns =>
  56. {
  57. columns.RelativeColumn();
  58. columns.RelativeColumn();
  59. });
  60. table.Cell()
  61. .Column(1)
  62. .Row(1)
  63. .RowSpan(3)
  64. .Mock("a")
  65. .SolidBlock(100, 100);
  66. table.Cell()
  67. .Column(2)
  68. .Row(2)
  69. .Mock("b")
  70. .ContinuousBlock(100, 600);
  71. });
  72. })
  73. .ExpectDrawResult(document =>
  74. {
  75. document
  76. .Page()
  77. .RequiredAreaSize(200, 400)
  78. .Content(page =>
  79. {
  80. page.Mock("a").Position(0, 0).Size(100, 400);
  81. page.Mock("b").Position(100, 0).Size(100, 400);
  82. });
  83. document
  84. .Page()
  85. .RequiredAreaSize(200, 200)
  86. .Content(page =>
  87. {
  88. page.Mock("a").Position(0, 0).Size(100, 200);
  89. page.Mock("b").Position(100, 0).Size(100, 200);
  90. });
  91. });
  92. }
  93. [Test]
  94. public void RowSpan_CornerCase3()
  95. {
  96. LayoutTest
  97. .HavingSpaceOfSize(200, 400)
  98. .ForContent(content =>
  99. {
  100. content
  101. .Table(table =>
  102. {
  103. table.ColumnsDefinition(columns =>
  104. {
  105. columns.RelativeColumn();
  106. });
  107. table.Cell()
  108. .Column(1)
  109. .Row(1)
  110. .RowSpan(3)
  111. .Column(column =>
  112. {
  113. foreach (var i in Enumerable.Range(1, 5))
  114. {
  115. column.Item().Width(200).Height(200).Mock($"{i}");
  116. }
  117. });
  118. });
  119. })
  120. .ExpectDrawResult(document =>
  121. {
  122. document
  123. .Page()
  124. .RequiredAreaSize(200, 400)
  125. .Content(page =>
  126. {
  127. page.Mock("1").Position(0, 0).Size(200, 200);
  128. page.Mock("2").Position(0, 200).Size(200, 200);
  129. });
  130. document
  131. .Page()
  132. .RequiredAreaSize(200, 400)
  133. .Content(page =>
  134. {
  135. page.Mock("3").Position(0, 0).Size(200, 200);
  136. page.Mock("4").Position(0, 200).Size(200, 200);
  137. });
  138. document
  139. .Page()
  140. .RequiredAreaSize(200, 200)
  141. .Content(page =>
  142. {
  143. page.Mock("5").Position(0, 0).Size(200, 200);
  144. });
  145. });
  146. }
  147. }