CanvasMock.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using QuestPDF.Infrastructure;
  3. using SkiaSharp;
  4. namespace QuestPDF.UnitTests.TestEngine
  5. {
  6. internal class CanvasMock : ICanvas
  7. {
  8. public Action<Position> TranslateFunc { get; set; }
  9. public Action<SKImage, Position, Size> DrawImageFunc { get; set; }
  10. public Action<string, Position, TextStyle> DrawTextFunc { get; set; }
  11. public Action<Position, Size, string> DrawRectFunc { get; set; }
  12. public void Translate(Position vector) => TranslateFunc(vector);
  13. public void DrawRectangle(Position vector, Size size, string color) => DrawRectFunc(vector, size, color);
  14. public void DrawText(string text, Position position, TextStyle style) => DrawTextFunc(text, position, style);
  15. public void DrawImage(SKImage image, Position position, Size size) => DrawImageFunc(image, position, size);
  16. public void DrawExternalLink(string url, Size size)
  17. {
  18. throw new NotImplementedException();
  19. }
  20. public void DrawLocationLink(string locationName, Size size)
  21. {
  22. throw new NotImplementedException();
  23. }
  24. public void DrawLocation(string locationName)
  25. {
  26. throw new NotImplementedException();
  27. }
  28. public void DrawLink(string url, Size size)
  29. {
  30. throw new NotImplementedException();
  31. }
  32. public Size MeasureText(string text, TextStyle style)
  33. {
  34. return new Size(text.Length * style.Size, style.Size);
  35. }
  36. }
  37. }