| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- using QuestPDF.Helpers;
- namespace QuestPDF.LayoutTests;
- public class SimpleRotateTests
- {
- private void DrawTestSubject(IContainer container)
- {
- container
- .Column(column =>
- {
- column.Item().Row(row =>
- {
- row.AutoItem().Mock("a").SolidBlock(100, 100);
- row.AutoItem().Mock("b").SolidBlock(100, 100);
- row.AutoItem().Mock("c").SolidBlock(100, 100);
- });
-
- column.Item().Row(row =>
- {
- row.AutoItem().Mock("d").SolidBlock(100, 100);
- row.AutoItem().Mock("e").SolidBlock(100, 100);
- row.AutoItem().Mock("f").SolidBlock(100, 100);
- });
- });
- }
-
- #region Single Page
-
- [Test]
- public void NoRotation()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 500)
- .ForContent(content =>
- {
- content.Shrink().Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(300, 200)
- .Content(page =>
- {
- page.Mock("a").Position(0, 0).Size(100, 100);
- page.Mock("b").Position(100, 0).Size(100, 100);
- page.Mock("c").Position(200, 0).Size(100, 100);
- page.Mock("d").Position(0, 100).Size(100, 100);
- page.Mock("e").Position(100, 100).Size(100, 100);
- page.Mock("f").Position(200, 100).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void OneRotation()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 500)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(200, 300)
- .Content(page =>
- {
- page.Mock("a").Position(200, 0).Size(100, 100);
- page.Mock("b").Position(200, 100).Size(100, 100);
- page.Mock("c").Position(200, 200).Size(100, 100);
- page.Mock("d").Position(100, 0).Size(100, 100);
- page.Mock("e").Position(100, 100).Size(100, 100);
- page.Mock("f").Position(100, 200).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void TwoRotations()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 500)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .RotateRight()
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(300, 200)
- .Content(page =>
- {
- page.Mock("a").Position(300, 200).Size(100, 100);
- page.Mock("b").Position(200, 200).Size(100, 100);
- page.Mock("c").Position(100, 200).Size(100, 100);
- page.Mock("d").Position(300, 100).Size(100, 100);
- page.Mock("e").Position(200, 100).Size(100, 100);
- page.Mock("f").Position(100, 100).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void ThreeRotation()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 500)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .RotateRight()
- .RotateRight()
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(200, 300)
- .Content(page =>
- {
- page.Mock("a").Position(0, 300).Size(100, 100);
- page.Mock("b").Position(0, 200).Size(100, 100);
- page.Mock("c").Position(0, 100).Size(100, 100);
- page.Mock("d").Position(100, 300).Size(100, 100);
- page.Mock("e").Position(100, 200).Size(100, 100);
- page.Mock("f").Position(100, 100).Size(100, 100);
- });
- });
- }
-
- #endregion
-
- #region Paging
-
- [Test]
- public void NoRotationWithPaging()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 150)
- .ForContent(content =>
- {
- content.Shrink().Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(300, 100)
- .Content(page =>
- {
- page.Mock("a").Position(0, 0).Size(100, 100);
- page.Mock("b").Position(100, 0).Size(100, 100);
- page.Mock("c").Position(200, 0).Size(100, 100);
- });
-
- document
- .Page()
- .RequiredAreaSize(300, 100)
- .Content(page =>
- {
- page.Mock("d").Position(0, 0).Size(100, 100);
- page.Mock("e").Position(100, 0).Size(100, 100);
- page.Mock("f").Position(200, 0).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void OneRotationWithPaging()
- {
- LayoutTest
- .HavingSpaceOfSize(150, 500)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(100, 300)
- .Content(page =>
- {
- page.Mock("a").Position(100, 0).Size(100, 100);
- page.Mock("b").Position(100, 100).Size(100, 100);
- page.Mock("c").Position(100, 200).Size(100, 100);
- });
-
- document
- .Page()
- .RequiredAreaSize(100, 300)
- .Content(page =>
- {
- page.Mock("d").Position(100, 0).Size(100, 100);
- page.Mock("e").Position(100, 100).Size(100, 100);
- page.Mock("f").Position(100, 200).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void TwoRotationsWithPaging()
- {
- LayoutTest
- .HavingSpaceOfSize(500, 150)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .RotateRight()
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(300, 100)
- .Content(page =>
- {
- page.Mock("a").Position(300, 100).Size(100, 100);
- page.Mock("b").Position(200, 100).Size(100, 100);
- page.Mock("c").Position(100, 100).Size(100, 100);
- });
-
- document
- .Page()
- .RequiredAreaSize(300, 100)
- .Content(page =>
- {
- page.Mock("d").Position(300, 100).Size(100, 100);
- page.Mock("e").Position(200, 100).Size(100, 100);
- page.Mock("f").Position(100, 100).Size(100, 100);
- });
- });
- }
-
- [Test]
- public void ThreeRotationWithPaging()
- {
- LayoutTest
- .HavingSpaceOfSize(150, 500)
- .ForContent(content =>
- {
- content
- .Shrink()
- .RotateRight() // <-
- .RotateRight()
- .RotateRight()
- .Element(DrawTestSubject);
- })
- .ExpectDrawResult(document =>
- {
- document
- .Page()
- .RequiredAreaSize(100, 300)
- .Content(page =>
- {
- page.Mock("a").Position(0, 300).Size(100, 100);
- page.Mock("b").Position(0, 200).Size(100, 100);
- page.Mock("c").Position(0, 100).Size(100, 100);
- });
-
- document
- .Page()
- .RequiredAreaSize(100, 300)
- .Content(page =>
- {
- page.Mock("d").Position(0, 300).Size(100, 100);
- page.Mock("e").Position(0, 200).Size(100, 100);
- page.Mock("f").Position(0, 100).Size(100, 100);
- });
- });
- }
-
- #endregion
- }
|