BorderTests.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 Avalonia.Media;
  4. using Avalonia.Rendering;
  5. using Avalonia.UnitTests;
  6. using Moq;
  7. using Xunit;
  8. namespace Avalonia.Controls.UnitTests
  9. {
  10. public class BorderTests
  11. {
  12. [Fact]
  13. public void Measure_Should_Return_BorderThickness_Plus_Padding_When_No_Child_Present()
  14. {
  15. var target = new Border
  16. {
  17. Padding = new Thickness(6),
  18. BorderThickness = new Thickness(4)
  19. };
  20. target.Measure(new Size(100, 100));
  21. Assert.Equal(new Size(20, 20), target.DesiredSize);
  22. }
  23. [Fact]
  24. public void Child_Should_Arrange_With_Zero_Height_Width_If_Padding_Greater_Than_Child_Size()
  25. {
  26. Border content;
  27. var target = new Border
  28. {
  29. Padding = new Thickness(6),
  30. MaxHeight = 12,
  31. MaxWidth = 12,
  32. Child = content = new Border
  33. {
  34. Height = 0,
  35. Width = 0
  36. }
  37. };
  38. target.Arrange(new Rect(0, 0, 100, 100));
  39. Assert.Equal(new Rect(6, 6, 0, 0), content.Bounds);
  40. }
  41. [Fact]
  42. public void Changing_Background_Brush_Color_Should_Invalidate_Visual()
  43. {
  44. var target = new Border()
  45. {
  46. Background = new SolidColorBrush(Colors.Red),
  47. };
  48. var root = new TestRoot(target);
  49. var renderer = Mock.Get(root.Renderer);
  50. renderer.ResetCalls();
  51. ((SolidColorBrush)target.Background).Color = Colors.Green;
  52. renderer.Verify(x => x.AddDirty(target), Times.Once);
  53. }
  54. }
  55. }