Files

54 lines
2.1 KiB
C#
Raw Permalink Normal View History

2021-10-01 02:32:35 +02: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;
using QuestPDF.UnitTests.TestEngine;
2021-01-16 01:31:39 +01:00
namespace QuestPDF.UnitTests
{
[TestFixture]
public class ShowOnceTest
{
[Test]
public void Draw()
2021-01-16 01:31:39 +01:00
{
TestPlan
.For(x => new ShowOnce()
{
Child = x.CreateChild()
2021-01-16 01:31:39 +01:00
})
// Measure the element and return result
.MeasureElement(new Size(300, 200))
2021-09-02 21:48:20 +02:00
.ExpectChildMeasure("child", new Size(300, 200), SpacePlan.PartialRender(new Size(200, 200)))
.CheckMeasureResult(SpacePlan.PartialRender(new Size(200, 200)))
2021-01-16 01:31:39 +01:00
// Draw element partially
.DrawElement(new Size(200, 200))
2021-09-02 21:48:20 +02:00
.ExpectChildMeasure(new Size(200, 200), SpacePlan.PartialRender(new Size(200, 200)))
.ExpectChildDraw(new Size(200, 200))
2021-01-16 01:31:39 +01:00
.CheckDrawResult()
// Element was not fully drawn
// It should be measured again for rendering on next page
.MeasureElement(new Size(800, 200))
2021-09-02 21:48:20 +02:00
.ExpectChildMeasure(new Size(800, 200), SpacePlan.FullRender(new Size(400, 200)))
.CheckMeasureResult(SpacePlan.FullRender(new Size(400, 200)))
2021-01-16 01:31:39 +01:00
// Draw element on next page
// Element was fully drawn at this point
.DrawElement(new Size(400, 200))
2021-09-02 21:48:20 +02:00
.ExpectChildMeasure(new Size(400, 200), SpacePlan.FullRender(new Size(400, 200)))
.ExpectChildDraw(new Size(400, 200))
2021-01-16 01:31:39 +01:00
.CheckDrawResult()
// In the next attempt of measuring element, it should behave like empty parent.
.MeasureElement(new Size(600, 200))
2021-09-02 21:48:20 +02:00
.CheckMeasureResult(SpacePlan.FullRender(0, 0))
2021-01-16 01:31:39 +01:00
// In the next attempt of measuring element, it should not draw its child
.DrawElement(new Size(600, 200))
.CheckDrawResult();
}
}
}