SingleChildTests.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using FluentAssertions;
  2. using NUnit.Framework;
  3. using QuestPDF.Drawing.SpacePlan;
  4. using QuestPDF.Infrastructure;
  5. namespace QuestPDF.UnitTests.TestEngine
  6. {
  7. public static class SingleChildTests
  8. {
  9. internal static void MeasureWithoutChild<T>(this T element) where T : ContainerElement
  10. {
  11. element.Child = null;
  12. element.Measure(Size.Zero).Should().BeEquivalentTo(new FullRender(Size.Zero));
  13. }
  14. internal static void DrawWithoutChild<T>(this T element) where T : ContainerElement
  15. {
  16. // component does not throw an exception when called with null child
  17. Assert.DoesNotThrow(() =>
  18. {
  19. element.Child = null;
  20. // component does not perform any canvas operation when called with null child
  21. TestPlan
  22. .For(x => element)
  23. .DrawElement(new Size(200, 100))
  24. .CheckDrawResult();
  25. });
  26. }
  27. }
  28. }