LayoutHelperTests.cs 832 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using Avalonia.Layout;
  3. using Xunit;
  4. namespace Avalonia.Base.UnitTests.Layout
  5. {
  6. public class LayoutHelperTests
  7. {
  8. [Fact]
  9. public void Round_Layout_Value_Without_DPI_Aware()
  10. {
  11. const double value = 42.5;
  12. var expectedValue = Math.Round(value);
  13. var actualValue = LayoutHelper.RoundLayoutValue(value, 1.0);
  14. Assert.Equal(expectedValue, actualValue);
  15. }
  16. [Fact]
  17. public void Round_Layout_Value_With_DPI_Aware()
  18. {
  19. const double dpiScale = 1.25;
  20. const double value = 42.5;
  21. var expectedValue = Math.Round(value * dpiScale) / dpiScale;
  22. var actualValue = LayoutHelper.RoundLayoutValue(value, dpiScale);
  23. Assert.Equal(expectedValue, actualValue);
  24. }
  25. }
  26. }