MeasureTests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Perspex.Controls;
  4. using Xunit;
  5. namespace Perspex.Layout.UnitTests
  6. {
  7. public class MeasureTests
  8. {
  9. [Fact]
  10. public void Negative_Margin_Larger_Than_Constraint_Should_Request_Width_0()
  11. {
  12. Control target;
  13. var outer = new Decorator
  14. {
  15. Width = 100,
  16. Height = 100,
  17. Child = target = new Control
  18. {
  19. Margin = new Thickness(-100, 0, 0, 0),
  20. }
  21. };
  22. outer.Measure(Size.Infinity);
  23. Assert.Equal(0, target.DesiredSize.Width);
  24. }
  25. [Fact]
  26. public void Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0()
  27. {
  28. Control target;
  29. var outer = new Decorator
  30. {
  31. Width = 100,
  32. Height = 100,
  33. Child = target = new Control
  34. {
  35. Margin = new Thickness(0, -100, 0, 0),
  36. }
  37. };
  38. outer.Measure(Size.Infinity);
  39. Assert.Equal(0, target.DesiredSize.Height);
  40. }
  41. }
  42. }