123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using Avalonia.Controls.Shapes;
- using Avalonia.UnitTests;
- using Xunit;
- namespace Avalonia.Controls.UnitTests
- {
- public class CanvasTests : ScopedTestBase
- {
- [Fact]
- public void Left_Property_Should_Work()
- {
- using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
- 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()
- {
- using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
- 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()
- {
- using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
- 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()
- {
- using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
- 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);
- }
- }
- }
|