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 ConstrainedTests
|
|
|
|
|
{
|
2021-10-12 23:58:28 +02:00
|
|
|
#region Height
|
|
|
|
|
|
2021-01-16 01:31:39 +01:00
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinHeight_ExpectWrap()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinHeight = 100
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 50))
|
2021-09-02 21:48:20 +02:00
|
|
|
.CheckMeasureResult(SpacePlan.Wrap());
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinHeight_ExtendHeight()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinHeight = 100,
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 200))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(new Size(400, 200), SpacePlan.FullRender(400, 50))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(400, 100));
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinHeight_PassHeight()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinHeight = 100,
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 200))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(new Size(400, 200), SpacePlan.FullRender(400, 150))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(400, 150));
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxHeight_Empty()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxHeight = 100
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 150))
|
2021-09-02 21:48:20 +02:00
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(0, 0));
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxHeight_PartialRender()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxHeight = 100,
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 200))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(new Size(400, 100), SpacePlan.PartialRender(400, 75))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.PartialRender(400, 75));
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxHeight_ExpectWrap()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxHeight = 100,
|
2021-03-23 18:05:39 +01:00
|
|
|
Child = x.CreateChild()
|
2021-01-16 01:31:39 +01:00
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(400, 200))
|
2021-09-02 21:48:20 +02:00
|
|
|
.ExpectChildMeasure(new Size(400, 100), SpacePlan.Wrap())
|
|
|
|
|
.CheckMeasureResult(SpacePlan.Wrap());
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
2021-10-12 23:58:28 +02:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Width
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinWidth_ExpectWrap()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinWidth = 100
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(50, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.CheckMeasureResult(SpacePlan.Wrap());
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinWidth_ExtendHeight()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinWidth = 100,
|
|
|
|
|
Child = x.CreateChild()
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(200, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.ExpectChildMeasure(new Size(200, 400), SpacePlan.FullRender(50, 400))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(100, 400));
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MinWidth_PassHeight()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MinWidth = 100,
|
|
|
|
|
Child = x.CreateChild()
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(200, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.ExpectChildMeasure(new Size(200, 400), SpacePlan.FullRender(150, 400))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(150, 400));
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxWidth_Empty()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxWidth = 100
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(150, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.CheckMeasureResult(SpacePlan.FullRender(0, 0));
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxWidth_PartialRender()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxWidth = 100,
|
|
|
|
|
Child = x.CreateChild()
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(200, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.ExpectChildMeasure(new Size(100, 400), SpacePlan.PartialRender(75, 400))
|
|
|
|
|
.CheckMeasureResult(SpacePlan.PartialRender(75, 400));
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Measure_MaxWidth_ExpectWrap()
|
|
|
|
|
{
|
|
|
|
|
TestPlan
|
|
|
|
|
.For(x => new Constrained
|
|
|
|
|
{
|
|
|
|
|
MaxWidth = 100,
|
|
|
|
|
Child = x.CreateChild()
|
|
|
|
|
})
|
|
|
|
|
.MeasureElement(new Size(200, 400))
|
2021-11-04 01:02:44 +01:00
|
|
|
.ExpectChildMeasure(new Size(100, 400), SpacePlan.Wrap())
|
|
|
|
|
.CheckMeasureResult(SpacePlan.Wrap());
|
2021-10-12 23:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-01-16 01:31:39 +01:00
|
|
|
}
|
|
|
|
|
}
|