Browse Source

Added failing PixelRect snapping tests.

pull/3909/head
Steven Kirk 6 years ago
parent
commit
313f334d1c
  1. 46
      tests/Avalonia.Visuals.UnitTests/Media/PixelRectTests.cs

46
tests/Avalonia.Visuals.UnitTests/Media/PixelRectTests.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
namespace Avalonia.Visuals.UnitTests.Media
{
public class PixelRectTests
{
[Fact]
public void FromRect_Snaps_To_Device_Pixels()
{
var rect = new Rect(189, 189, 26, 164);
var result = PixelRect.FromRect(rect, 1.5);
Assert.Equal(new PixelRect(283, 283, 40, 247), result);
}
[Fact]
public void FromRect_Vector_Snaps_To_Device_Pixels()
{
var rect = new Rect(189, 189, 26, 164);
var result = PixelRect.FromRect(rect, new Vector(1.5, 1.5));
Assert.Equal(new PixelRect(283, 283, 40, 247), result);
}
[Fact]
public void FromRectWithDpi_Snaps_To_Device_Pixels()
{
var rect = new Rect(189, 189, 26, 164);
var result = PixelRect.FromRectWithDpi(rect, 144);
Assert.Equal(new PixelRect(283, 283, 40, 247), result);
}
[Fact]
public void FromRectWithDpi_Vector_Snaps_To_Device_Pixels()
{
var rect = new Rect(189, 189, 26, 164);
var result = PixelRect.FromRectWithDpi(rect, new Vector(144, 144));
Assert.Equal(new PixelRect(283, 283, 40, 247), result);
}
}
}
Loading…
Cancel
Save