ShrinkTests.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. namespace QuestPDF.LayoutTests;
  2. public class ShrinkTests
  3. {
  4. [Test]
  5. public void Both()
  6. {
  7. LayoutTest
  8. .HavingSpaceOfSize(100, 120)
  9. .ForContent(content =>
  10. {
  11. content
  12. .Shrink()
  13. .Mock("a").ContinuousBlock(60, 200);
  14. })
  15. .ExpectDrawResult(document =>
  16. {
  17. document
  18. .Page()
  19. .RequiredAreaSize(60, 120)
  20. .Content(page =>
  21. {
  22. page.Mock("a").Position(0, 0).Size(60, 120);
  23. });
  24. document
  25. .Page()
  26. .RequiredAreaSize(60, 80)
  27. .Content(page =>
  28. {
  29. page.Mock("a").Position(0, 0).Size(60, 80);
  30. });
  31. });
  32. }
  33. [Test]
  34. public void Vertical()
  35. {
  36. LayoutTest
  37. .HavingSpaceOfSize(100, 120)
  38. .ForContent(content =>
  39. {
  40. content
  41. .ShrinkVertical()
  42. .Mock("a").ContinuousBlock(60, 200);
  43. })
  44. .ExpectDrawResult(document =>
  45. {
  46. document
  47. .Page()
  48. .RequiredAreaSize(60, 120)
  49. .Content(page =>
  50. {
  51. page.Mock("a").Position(0, 0).Size(100, 120);
  52. });
  53. document
  54. .Page()
  55. .RequiredAreaSize(60, 80)
  56. .Content(page =>
  57. {
  58. page.Mock("a").Position(0, 0).Size(100, 80);
  59. });
  60. });
  61. }
  62. [Test]
  63. public void Horizontal()
  64. {
  65. LayoutTest
  66. .HavingSpaceOfSize(100, 120)
  67. .ForContent(content =>
  68. {
  69. content
  70. .ShrinkHorizontal()
  71. .Mock("a").ContinuousBlock(60, 200);
  72. })
  73. .ExpectDrawResult(document =>
  74. {
  75. document
  76. .Page()
  77. .RequiredAreaSize(60, 120)
  78. .Content(page =>
  79. {
  80. page.Mock("a").Position(0, 0).Size(60, 120);
  81. });
  82. document
  83. .Page()
  84. .RequiredAreaSize(60, 80)
  85. .Content(page =>
  86. {
  87. page.Mock("a").Position(0, 0).Size(60, 120);
  88. });
  89. });
  90. }
  91. [Test]
  92. public void ContentFromRightToLeft()
  93. {
  94. LayoutTest
  95. .HavingSpaceOfSize(100, 120)
  96. .ForContent(content =>
  97. {
  98. content
  99. .ContentFromRightToLeft()
  100. .Shrink()
  101. .Mock("a").ContinuousBlock(60, 200);
  102. })
  103. .ExpectDrawResult(document =>
  104. {
  105. document
  106. .Page()
  107. .RequiredAreaSize(60, 120)
  108. .Content(page =>
  109. {
  110. page.Mock("a").Position(40, 0).Size(60, 120);
  111. });
  112. document
  113. .Page()
  114. .RequiredAreaSize(60, 80)
  115. .Content(page =>
  116. {
  117. page.Mock("a").Position(40, 0).Size(60, 80);
  118. });
  119. });
  120. }
  121. }