BorderTests.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using NUnit.Framework;
  2. using QuestPDF.Drawing.SpacePlan;
  3. using QuestPDF.Elements;
  4. using QuestPDF.Infrastructure;
  5. using QuestPDF.UnitTests.TestEngine;
  6. namespace QuestPDF.UnitTests
  7. {
  8. [TestFixture]
  9. public class BorderTests
  10. {
  11. [Test]
  12. public void Measure_ShouldHandleNullChild() => new Border().MeasureWithoutChild();
  13. [Test]
  14. public void ComponentShouldNotAffectLayout()
  15. {
  16. TestPlan
  17. .For(x => new Border
  18. {
  19. Top = 10,
  20. Right = 20,
  21. Bottom = 30,
  22. Left = 40,
  23. Child = x.CreateChild("child")
  24. })
  25. .MeasureElement(new Size(400, 300))
  26. .ExpectChildMeasure("child", expectedInput: new Size(400, 300), returns: new FullRender(new Size(100, 50)))
  27. .CheckMeasureResult( new FullRender(new Size(100, 50)));
  28. }
  29. [Test]
  30. public void Draw_HorizontalRight_VerticalTop()
  31. {
  32. TestPlan
  33. .For(x => new Border
  34. {
  35. Top = 10,
  36. Right = 20,
  37. Bottom = 30,
  38. Left = 40,
  39. Color = "#FF0000",
  40. Child = x.CreateChild("child")
  41. })
  42. .DrawElement(new Size(400, 300))
  43. .ExpectChildDraw("child", new Size(400, 300))
  44. .ExpectCanvasDrawRectangle(new Position(-20, -5), new Size(430, 10), "#FF0000") // top
  45. .ExpectCanvasDrawRectangle(new Position(-20, -5), new Size(40, 320), "#FF0000") // left
  46. .ExpectCanvasDrawRectangle(new Position(-20, 285), new Size(430, 30), "#FF0000") // bottom
  47. .ExpectCanvasDrawRectangle(new Position(390, -5), new Size(20, 320), "#FF0000") // right
  48. .ExpectChildDraw("child", new Size(400, 300))
  49. .CheckDrawResult();
  50. }
  51. }
  52. }