RelativeRectTests.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 System;
  4. using System.Globalization;
  5. using Xunit;
  6. namespace Avalonia.Visuals.UnitTests
  7. {
  8. public class RelativeRectTests
  9. {
  10. private static readonly RelativeRectComparer Compare = new RelativeRectComparer();
  11. [Fact]
  12. public void Parse_Should_Accept_Absolute_Value()
  13. {
  14. var result = RelativeRect.Parse("4,5,50,60");
  15. Assert.Equal(new RelativeRect(4, 5, 50, 60, RelativeUnit.Absolute), result, Compare);
  16. }
  17. [Fact]
  18. public void Parse_Should_Accept_Relative_Value()
  19. {
  20. var result = RelativeRect.Parse("10%, 20%, 40%, 70%");
  21. Assert.Equal(new RelativeRect(0.1, 0.2, 0.4, 0.7, RelativeUnit.Relative), result, Compare);
  22. }
  23. [Fact]
  24. public void Parse_Should_Throw_Mixed_Values()
  25. {
  26. Assert.Throws<FormatException>(() =>
  27. RelativeRect.Parse("10%, 20%, 40, 70%"));
  28. }
  29. }
  30. }