2021-01-16 01:31:39 +01:00
|
|
|
using NUnit.Framework;
|
2021-09-02 21:48:20 +02:00
|
|
|
using QuestPDF.Drawing;
|
2021-01-16 01:31:39 +01:00
|
|
|
using QuestPDF.Elements;
|
|
|
|
|
using QuestPDF.Infrastructure;
|
2021-02-08 14:36:12 +01:00
|
|
|
using QuestPDF.UnitTests.TestEngine;
|
2021-01-16 01:31:39 +01:00
|
|
|
|
|
|
|
|
namespace QuestPDF.UnitTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class AlignmentTests
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
2021-09-18 01:21:48 +02:00
|
|
|
public void Measure() => SimpleContainerTests.Measure<Alignment>();
|
2021-01-16 01:31:39 +01:00
|
|
|
[Test]
|
|
|
|
|
public void Draw_HorizontalCenter_VerticalCenter()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Alignment
|
|
|
|
|
{
|
|
|
|
|
Horizontal = HorizontalAlignment.Center,
|
|
|
|
|
Vertical = VerticalAlignment.Middle,
|
|
|
|
|
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.DrawElement(new Size(1000, 500))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(expectedInput: new Size(1000, 500), returns: SpacePlan.PartialRender(new Size(400, 200)))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(300, 150))
|
2021-03-23 18:05:39 +01:00
|
|
|
.ExpectChildDraw(new Size(400, 200))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(-300, -150))
|
|
|
|
|
.CheckDrawResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Draw_HorizontalLeft_VerticalCenter()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Alignment
|
|
|
|
|
{
|
|
|
|
|
Horizontal = HorizontalAlignment.Left,
|
|
|
|
|
Vertical = VerticalAlignment.Middle,
|
|
|
|
|
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.DrawElement(new Size(400, 300))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.FullRender(new Size(100, 50)))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(0, 125))
|
2021-03-23 18:05:39 +01:00
|
|
|
.ExpectChildDraw(new Size(100, 50))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(0, -125))
|
|
|
|
|
.CheckDrawResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Draw_HorizontalCenter_VerticalBottom()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Alignment
|
|
|
|
|
{
|
|
|
|
|
Horizontal = HorizontalAlignment.Center,
|
|
|
|
|
Vertical = VerticalAlignment.Bottom,
|
|
|
|
|
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.DrawElement(new Size(400, 300))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.FullRender(new Size(100, 50)))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(150, 250))
|
2021-03-23 18:05:39 +01:00
|
|
|
.ExpectChildDraw(new Size(100, 50))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(-150, -250))
|
|
|
|
|
.CheckDrawResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Draw_HorizontalRight_VerticalTop()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Alignment
|
|
|
|
|
{
|
|
|
|
|
Horizontal = HorizontalAlignment.Right,
|
|
|
|
|
Vertical = VerticalAlignment.Top,
|
|
|
|
|
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.DrawElement(new Size(400, 300))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.FullRender(new Size(100, 50)))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(300, 0))
|
2021-03-23 18:05:39 +01:00
|
|
|
.ExpectChildDraw(new Size(100, 50))
|
2021-01-16 01:31:39 +01:00
|
|
|
.ExpectCanvasTranslate(new Position(-300, 0))
|
|
|
|
|
.CheckDrawResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|