SimpleRotateTests.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using QuestPDF.Helpers;
  2. namespace QuestPDF.LayoutTests;
  3. public class SimpleRotateTests
  4. {
  5. private void DrawTestSubject(IContainer container)
  6. {
  7. container
  8. .Column(column =>
  9. {
  10. column.Item().Row(row =>
  11. {
  12. row.AutoItem().Mock("a").SolidBlock(100, 100);
  13. row.AutoItem().Mock("b").SolidBlock(100, 100);
  14. row.AutoItem().Mock("c").SolidBlock(100, 100);
  15. });
  16. column.Item().Row(row =>
  17. {
  18. row.AutoItem().Mock("d").SolidBlock(100, 100);
  19. row.AutoItem().Mock("e").SolidBlock(100, 100);
  20. row.AutoItem().Mock("f").SolidBlock(100, 100);
  21. });
  22. });
  23. }
  24. #region Single Page
  25. [Test]
  26. public void NoRotation()
  27. {
  28. LayoutTest
  29. .HavingSpaceOfSize(500, 500)
  30. .ForContent(content =>
  31. {
  32. content.Shrink().Element(DrawTestSubject);
  33. })
  34. .ExpectDrawResult(document =>
  35. {
  36. document
  37. .Page()
  38. .RequiredAreaSize(300, 200)
  39. .Content(page =>
  40. {
  41. page.Mock("a").Position(0, 0).Size(100, 100);
  42. page.Mock("b").Position(100, 0).Size(100, 100);
  43. page.Mock("c").Position(200, 0).Size(100, 100);
  44. page.Mock("d").Position(0, 100).Size(100, 100);
  45. page.Mock("e").Position(100, 100).Size(100, 100);
  46. page.Mock("f").Position(200, 100).Size(100, 100);
  47. });
  48. });
  49. }
  50. [Test]
  51. public void OneRotation()
  52. {
  53. LayoutTest
  54. .HavingSpaceOfSize(500, 500)
  55. .ForContent(content =>
  56. {
  57. content
  58. .Shrink()
  59. .RotateRight() // <-
  60. .Element(DrawTestSubject);
  61. })
  62. .ExpectDrawResult(document =>
  63. {
  64. document
  65. .Page()
  66. .RequiredAreaSize(200, 300)
  67. .Content(page =>
  68. {
  69. page.Mock("a").Position(200, 0).Size(100, 100);
  70. page.Mock("b").Position(200, 100).Size(100, 100);
  71. page.Mock("c").Position(200, 200).Size(100, 100);
  72. page.Mock("d").Position(100, 0).Size(100, 100);
  73. page.Mock("e").Position(100, 100).Size(100, 100);
  74. page.Mock("f").Position(100, 200).Size(100, 100);
  75. });
  76. });
  77. }
  78. [Test]
  79. public void TwoRotations()
  80. {
  81. LayoutTest
  82. .HavingSpaceOfSize(500, 500)
  83. .ForContent(content =>
  84. {
  85. content
  86. .Shrink()
  87. .RotateRight() // <-
  88. .RotateRight()
  89. .Element(DrawTestSubject);
  90. })
  91. .ExpectDrawResult(document =>
  92. {
  93. document
  94. .Page()
  95. .RequiredAreaSize(300, 200)
  96. .Content(page =>
  97. {
  98. page.Mock("a").Position(300, 200).Size(100, 100);
  99. page.Mock("b").Position(200, 200).Size(100, 100);
  100. page.Mock("c").Position(100, 200).Size(100, 100);
  101. page.Mock("d").Position(300, 100).Size(100, 100);
  102. page.Mock("e").Position(200, 100).Size(100, 100);
  103. page.Mock("f").Position(100, 100).Size(100, 100);
  104. });
  105. });
  106. }
  107. [Test]
  108. public void ThreeRotation()
  109. {
  110. LayoutTest
  111. .HavingSpaceOfSize(500, 500)
  112. .ForContent(content =>
  113. {
  114. content
  115. .Shrink()
  116. .RotateRight() // <-
  117. .RotateRight()
  118. .RotateRight()
  119. .Element(DrawTestSubject);
  120. })
  121. .ExpectDrawResult(document =>
  122. {
  123. document
  124. .Page()
  125. .RequiredAreaSize(200, 300)
  126. .Content(page =>
  127. {
  128. page.Mock("a").Position(0, 300).Size(100, 100);
  129. page.Mock("b").Position(0, 200).Size(100, 100);
  130. page.Mock("c").Position(0, 100).Size(100, 100);
  131. page.Mock("d").Position(100, 300).Size(100, 100);
  132. page.Mock("e").Position(100, 200).Size(100, 100);
  133. page.Mock("f").Position(100, 100).Size(100, 100);
  134. });
  135. });
  136. }
  137. #endregion
  138. #region Paging
  139. [Test]
  140. public void NoRotationWithPaging()
  141. {
  142. LayoutTest
  143. .HavingSpaceOfSize(500, 150)
  144. .ForContent(content =>
  145. {
  146. content.Shrink().Element(DrawTestSubject);
  147. })
  148. .ExpectDrawResult(document =>
  149. {
  150. document
  151. .Page()
  152. .RequiredAreaSize(300, 100)
  153. .Content(page =>
  154. {
  155. page.Mock("a").Position(0, 0).Size(100, 100);
  156. page.Mock("b").Position(100, 0).Size(100, 100);
  157. page.Mock("c").Position(200, 0).Size(100, 100);
  158. });
  159. document
  160. .Page()
  161. .RequiredAreaSize(300, 100)
  162. .Content(page =>
  163. {
  164. page.Mock("d").Position(0, 0).Size(100, 100);
  165. page.Mock("e").Position(100, 0).Size(100, 100);
  166. page.Mock("f").Position(200, 0).Size(100, 100);
  167. });
  168. });
  169. }
  170. [Test]
  171. public void OneRotationWithPaging()
  172. {
  173. LayoutTest
  174. .HavingSpaceOfSize(150, 500)
  175. .ForContent(content =>
  176. {
  177. content
  178. .Shrink()
  179. .RotateRight() // <-
  180. .Element(DrawTestSubject);
  181. })
  182. .ExpectDrawResult(document =>
  183. {
  184. document
  185. .Page()
  186. .RequiredAreaSize(100, 300)
  187. .Content(page =>
  188. {
  189. page.Mock("a").Position(100, 0).Size(100, 100);
  190. page.Mock("b").Position(100, 100).Size(100, 100);
  191. page.Mock("c").Position(100, 200).Size(100, 100);
  192. });
  193. document
  194. .Page()
  195. .RequiredAreaSize(100, 300)
  196. .Content(page =>
  197. {
  198. page.Mock("d").Position(100, 0).Size(100, 100);
  199. page.Mock("e").Position(100, 100).Size(100, 100);
  200. page.Mock("f").Position(100, 200).Size(100, 100);
  201. });
  202. });
  203. }
  204. [Test]
  205. public void TwoRotationsWithPaging()
  206. {
  207. LayoutTest
  208. .HavingSpaceOfSize(500, 150)
  209. .ForContent(content =>
  210. {
  211. content
  212. .Shrink()
  213. .RotateRight() // <-
  214. .RotateRight()
  215. .Element(DrawTestSubject);
  216. })
  217. .ExpectDrawResult(document =>
  218. {
  219. document
  220. .Page()
  221. .RequiredAreaSize(300, 100)
  222. .Content(page =>
  223. {
  224. page.Mock("a").Position(300, 100).Size(100, 100);
  225. page.Mock("b").Position(200, 100).Size(100, 100);
  226. page.Mock("c").Position(100, 100).Size(100, 100);
  227. });
  228. document
  229. .Page()
  230. .RequiredAreaSize(300, 100)
  231. .Content(page =>
  232. {
  233. page.Mock("d").Position(300, 100).Size(100, 100);
  234. page.Mock("e").Position(200, 100).Size(100, 100);
  235. page.Mock("f").Position(100, 100).Size(100, 100);
  236. });
  237. });
  238. }
  239. [Test]
  240. public void ThreeRotationWithPaging()
  241. {
  242. LayoutTest
  243. .HavingSpaceOfSize(150, 500)
  244. .ForContent(content =>
  245. {
  246. content
  247. .Shrink()
  248. .RotateRight() // <-
  249. .RotateRight()
  250. .RotateRight()
  251. .Element(DrawTestSubject);
  252. })
  253. .ExpectDrawResult(document =>
  254. {
  255. document
  256. .Page()
  257. .RequiredAreaSize(100, 300)
  258. .Content(page =>
  259. {
  260. page.Mock("a").Position(0, 300).Size(100, 100);
  261. page.Mock("b").Position(0, 200).Size(100, 100);
  262. page.Mock("c").Position(0, 100).Size(100, 100);
  263. });
  264. document
  265. .Page()
  266. .RequiredAreaSize(100, 300)
  267. .Content(page =>
  268. {
  269. page.Mock("d").Position(0, 300).Size(100, 100);
  270. page.Mock("e").Position(0, 200).Size(100, 100);
  271. page.Mock("f").Position(0, 100).Size(100, 100);
  272. });
  273. });
  274. }
  275. #endregion
  276. }