PointTests.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. namespace Terminal.Gui.TypeTests;
  2. public class PointTests
  3. {
  4. [Fact]
  5. public void Point_Equals ()
  6. {
  7. var point1 = new Point ();
  8. var point2 = new Point ();
  9. Assert.Equal (point1, point2);
  10. point1 = new Point (1, 2);
  11. point2 = new Point (1, 2);
  12. Assert.Equal (point1, point2);
  13. point1 = new Point (1, 2);
  14. point2 = new Point (0, 2);
  15. Assert.NotEqual (point1, point2);
  16. point1 = new Point (1, 2);
  17. point2 = new Point (0, 3);
  18. Assert.NotEqual (point1, point2);
  19. }
  20. [Fact]
  21. public void Point_New ()
  22. {
  23. var point = new Point ();
  24. Assert.True (point.IsEmpty);
  25. point = new Point (new Size ());
  26. Assert.True (point.IsEmpty);
  27. point = new Point (1, 2);
  28. Assert.False (point.IsEmpty);
  29. point = new Point (-1, -2);
  30. Assert.False (point.IsEmpty);
  31. }
  32. [Fact]
  33. public void Point_SetsValue ()
  34. {
  35. var point = new Point { X = 0, Y = 0 };
  36. Assert.True (point.IsEmpty);
  37. point = new Point { X = 1, Y = 2 };
  38. Assert.False (point.IsEmpty);
  39. point = new Point { X = -1, Y = -2 };
  40. Assert.False (point.IsEmpty);
  41. }
  42. [Fact]
  43. public void Point_Size ()
  44. {
  45. var point = new Point (1, 2);
  46. var size = (Size)point;
  47. Assert.False (size.IsEmpty);
  48. point = new Point (-1, 2);
  49. Action action = () => size = (Size)point;
  50. var ex = Assert.Throws<ArgumentException> (action);
  51. Assert.Equal ("Either Width and Height must be greater or equal to 0.", ex.Message);
  52. }
  53. }