RectTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Xunit;
  4. namespace Avalonia.Visuals.UnitTests
  5. {
  6. public class RectTests
  7. {
  8. [Fact]
  9. public void Union_Should_Return_Correct_Value_For_Intersecting_Rects()
  10. {
  11. var result = new Rect(0, 0, 100, 100).Union(new Rect(50, 50, 100, 100));
  12. Assert.Equal(new Rect(0, 0, 150, 150), result);
  13. }
  14. [Fact]
  15. public void Union_Should_Return_Correct_Value_For_NonIntersecting_Rects()
  16. {
  17. var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 100, 100));
  18. Assert.Equal(new Rect(0, 0, 250, 250), result);
  19. }
  20. [Fact]
  21. public void Union_Should_Ignore_Empty_This_rect()
  22. {
  23. var result = new Rect(0, 0, 0, 0).Union(new Rect(150, 150, 100, 100));
  24. Assert.Equal(new Rect(150, 150, 100, 100), result);
  25. }
  26. [Fact]
  27. public void Union_Should_Ignore_Empty_Other_rect()
  28. {
  29. var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 0, 0));
  30. Assert.Equal(new Rect(0, 0, 100, 100), result);
  31. }
  32. }
  33. }