Improved null safety. Fixed tests
This commit is contained in:
@@ -16,7 +16,7 @@ namespace QuestPDF.UnitTests
|
||||
.For(x => new PageBreak())
|
||||
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.CheckMeasureResult(new PartialRender(400, 300))
|
||||
.CheckMeasureResult(new PartialRender(Size.Zero))
|
||||
|
||||
.DrawElement(new Size(400, 300))
|
||||
.CheckDrawResult()
|
||||
|
||||
@@ -205,6 +205,8 @@ namespace QuestPDF.UnitTests.TestEngine
|
||||
|
||||
public TestPlan CheckMeasureResult(ISpacePlan expected)
|
||||
{
|
||||
Element.HandleVisitor(x => x?.Initialize(null, Canvas));
|
||||
|
||||
var actual = Element.Measure(OperationInput);
|
||||
|
||||
Assert.AreEqual(expected.GetType(), actual.GetType());
|
||||
@@ -223,6 +225,7 @@ namespace QuestPDF.UnitTests.TestEngine
|
||||
|
||||
public TestPlan CheckDrawResult()
|
||||
{
|
||||
Element.HandleVisitor(x => x?.Initialize(null, Canvas));
|
||||
Element.Draw(OperationInput);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace QuestPDF.Drawing
|
||||
private static void RenderPass<TCanvas>(PageContext pageContext, TCanvas canvas, Container content, DocumentMetadata documentMetadata)
|
||||
where TCanvas : ICanvas, IRenderingCanvas
|
||||
{
|
||||
content.HandleVisitor(x => x.Initialize(pageContext, canvas));
|
||||
content.HandleVisitor(x => x?.Initialize(pageContext, canvas));
|
||||
content.HandleVisitor(x => (x as IStateResettable)?.ResetState());
|
||||
|
||||
canvas.BeginDocument();
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace QuestPDF.Elements
|
||||
|
||||
internal override void HandleVisitor(Action<Element?> visit)
|
||||
{
|
||||
DecorationElement.HandleVisitor(visit);
|
||||
ContentElement.HandleVisitor(visit);
|
||||
DecorationElement?.HandleVisitor(visit);
|
||||
ContentElement?.HandleVisitor(visit);
|
||||
|
||||
base.HandleVisitor(visit);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace QuestPDF.Elements
|
||||
|
||||
internal override void HandleVisitor(Action<Element?> visit)
|
||||
{
|
||||
TextElement.HandleVisitor(visit);
|
||||
TextElement?.HandleVisitor(visit);
|
||||
base.HandleVisitor(visit);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace QuestPDF.Elements
|
||||
|
||||
internal override void HandleVisitor(Action<Element?> visit)
|
||||
{
|
||||
First.HandleVisitor(visit);
|
||||
Second.HandleVisitor(visit);
|
||||
First?.HandleVisitor(visit);
|
||||
Second?.HandleVisitor(visit);
|
||||
|
||||
base.HandleVisitor(visit);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace QuestPDF.Infrastructure
|
||||
internal override void HandleVisitor(Action<Element?> visit)
|
||||
{
|
||||
base.HandleVisitor(visit);
|
||||
Child.HandleVisitor(visit);
|
||||
Child?.HandleVisitor(visit);
|
||||
}
|
||||
|
||||
internal override ISpacePlan Measure(Size availableSpace)
|
||||
|
||||
Reference in New Issue
Block a user