PixelRectTests.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Xunit;
  5. namespace Avalonia.Visuals.UnitTests.Media
  6. {
  7. public class PixelRectTests
  8. {
  9. [Fact]
  10. public void FromRect_Snaps_To_Device_Pixels()
  11. {
  12. var rect = new Rect(189, 189, 26, 164);
  13. var result = PixelRect.FromRect(rect, 1.5);
  14. Assert.Equal(new PixelRect(283, 283, 40, 247), result);
  15. }
  16. [Fact]
  17. public void FromRect_Vector_Snaps_To_Device_Pixels()
  18. {
  19. var rect = new Rect(189, 189, 26, 164);
  20. var result = PixelRect.FromRect(rect, new Vector(1.5, 1.5));
  21. Assert.Equal(new PixelRect(283, 283, 40, 247), result);
  22. }
  23. [Fact]
  24. public void FromRectWithDpi_Snaps_To_Device_Pixels()
  25. {
  26. var rect = new Rect(189, 189, 26, 164);
  27. var result = PixelRect.FromRectWithDpi(rect, 144);
  28. Assert.Equal(new PixelRect(283, 283, 40, 247), result);
  29. }
  30. [Fact]
  31. public void FromRectWithDpi_Vector_Snaps_To_Device_Pixels()
  32. {
  33. var rect = new Rect(189, 189, 26, 164);
  34. var result = PixelRect.FromRectWithDpi(rect, new Vector(144, 144));
  35. Assert.Equal(new PixelRect(283, 283, 40, 247), result);
  36. }
  37. }
  38. }