A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

109 lines
2.8 KiB

using System;
using Avalonia.Controls.Shapes;
using Xunit;
namespace Avalonia.Controls.UnitTests
{
public class CanvasTests
{
[Fact]
public void Left_Property_Should_Work()
{
Rectangle rect;
var target = new Canvas
{
Width = 400,
Height = 400,
Children =
{
(rect = new Rectangle
{
MinWidth = 20,
MinHeight = 25,
[Canvas.LeftProperty] = 30,
})
}
};
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Rect(30, 0, 20, 25), rect.Bounds);
}
[Fact]
public void Top_Property_Should_Work()
{
Rectangle rect;
var target = new Canvas
{
Width = 400,
Height = 400,
Children =
{
(rect = new Rectangle
{
MinWidth = 20,
MinHeight = 25,
[Canvas.TopProperty] = 30,
})
}
};
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Rect(0, 30, 20, 25), rect.Bounds);
}
[Fact]
public void Right_Property_Should_Work()
{
Rectangle rect;
var target = new Canvas
{
Width = 400,
Height = 400,
Children =
{
(rect = new Rectangle
{
MinWidth = 20,
MinHeight = 25,
[Canvas.RightProperty] = 30,
})
}
};
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Rect(350, 0, 20, 25), rect.Bounds);
}
[Fact]
public void Bottom_Property_Should_Work()
{
Rectangle rect;
var target = new Canvas
{
Width = 400,
Height = 400,
Children =
{
(rect = new Rectangle
{
MinWidth = 20,
MinHeight = 25,
[Canvas.BottomProperty] = 30,
})
}
};
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Rect(0, 345, 20, 25), rect.Bounds);
}
}
}