SimpleRotateTests.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using NUnit.Framework;
  2. using QuestPDF.Elements;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Infrastructure;
  5. namespace QuestPDF.UnitTests
  6. {
  7. [TestFixture]
  8. public class SimpleRotateTests
  9. {
  10. #region Cumulative rotation
  11. [Test]
  12. public void RotateRightIsCumulative()
  13. {
  14. var container = EmptyContainer.Create();
  15. container
  16. .RotateRight()
  17. .RotateRight()
  18. .RotateRight()
  19. .RotateRight()
  20. .RotateRight();
  21. var rotation = container.Child as SimpleRotate;
  22. Assert.That(rotation?.TurnCount, Is.EqualTo(5));
  23. }
  24. [Test]
  25. public void RotateLeftIsCumulative()
  26. {
  27. var container = EmptyContainer.Create();
  28. container
  29. .RotateLeft()
  30. .RotateLeft()
  31. .RotateLeft()
  32. .RotateLeft()
  33. .RotateLeft()
  34. .RotateLeft();
  35. var rotation = container.Child as SimpleRotate;
  36. Assert.That(rotation?.TurnCount, Is.EqualTo(-6));
  37. }
  38. [Test]
  39. public void RotateRightAndLeftCanBeCombined()
  40. {
  41. var container = EmptyContainer.Create();
  42. container
  43. .RotateRight()
  44. .RotateRight()
  45. .RotateRight()
  46. .RotateRight()
  47. .RotateLeft()
  48. .RotateLeft()
  49. .RotateLeft();
  50. var rotation = container.Child as SimpleRotate;
  51. Assert.That(rotation?.TurnCount, Is.EqualTo(1));
  52. }
  53. #endregion
  54. #region Companion Hint
  55. [Test]
  56. public void NoRotationCompanionHint()
  57. {
  58. var container = EmptyContainer.Create();
  59. container.RotateRight().RotateLeft();
  60. var rotation = container.Child as SimpleRotate;
  61. Assert.That(rotation?.GetCompanionHint(), Is.EqualTo("No rotation"));
  62. }
  63. [Test]
  64. public void RotateRightCompanionHint()
  65. {
  66. var container = EmptyContainer.Create();
  67. container.RotateRight();
  68. var rotation = container.Child as SimpleRotate;
  69. Assert.That(rotation?.GetCompanionHint(), Is.EqualTo("90 deg clockwise"));
  70. }
  71. [Test]
  72. public void DoubleRotateLeftCompanionHint()
  73. {
  74. var container = EmptyContainer.Create();
  75. container.RotateLeft().RotateLeft();
  76. var rotation = container.Child as SimpleRotate;
  77. Assert.That(rotation?.GetCompanionHint(), Is.EqualTo("180 deg counter-clockwise"));
  78. }
  79. #endregion
  80. }
  81. }