ShowIfTests.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. namespace QuestPDF.LayoutTests;
  2. public class ShowIfTests
  3. {
  4. [Test]
  5. public void Scenario()
  6. {
  7. LayoutTest
  8. .HavingSpaceOfSize(100, 100)
  9. .ForContent(content =>
  10. {
  11. content.Decoration(decoration =>
  12. {
  13. decoration.Before().ShowIf(c => c.PageNumber % 2 == 0).Mock("before").Size(80, 20);
  14. decoration.Content().Mock("content").ContinuousBlock(70, 460);
  15. decoration.After().ShowIf(c => c.PageNumber % 3 == 0).Mock("after").Size(90, 30);
  16. });
  17. })
  18. .ExpectDrawResult(document =>
  19. {
  20. document
  21. .Page()
  22. .RequiredAreaSize(70, 100)
  23. .Content(page =>
  24. {
  25. page.Mock("content").Position(0, 0).Size(70, 100);
  26. });
  27. document
  28. .Page()
  29. .RequiredAreaSize(80, 100)
  30. .Content(page =>
  31. {
  32. page.Mock("before").Position(0, 0).Size(80, 20);
  33. page.Mock("content").Position(0, 20).Size(80, 80);
  34. });
  35. document
  36. .Page()
  37. .RequiredAreaSize(90, 100)
  38. .Content(page =>
  39. {
  40. page.Mock("content").Position(0, 0).Size(90, 70);
  41. page.Mock("after").Position(0, 70).Size(90, 30);
  42. });
  43. document
  44. .Page()
  45. .RequiredAreaSize(80, 100)
  46. .Content(page =>
  47. {
  48. page.Mock("before").Position(0, 0).Size(80, 20);
  49. page.Mock("content").Position(0, 20).Size(80, 80);
  50. });
  51. document
  52. .Page()
  53. .RequiredAreaSize(70, 100)
  54. .Content(page =>
  55. {
  56. page.Mock("content").Position(0, 0).Size(70, 100);
  57. });
  58. document
  59. .Page()
  60. .RequiredAreaSize(90, 80)
  61. .Content(page =>
  62. {
  63. page.Mock("before").Position(0, 0).Size(90, 20);
  64. page.Mock("content").Position(0, 20).Size(90, 30);
  65. page.Mock("after").Position(0, 50).Size(90, 30);
  66. });
  67. });
  68. }
  69. }