csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
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.
54 lines
1.9 KiB
54 lines
1.9 KiB
// Copyright (c) The Perspex Project. All rights reserved.
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using Perspex.Controls;
|
|
using Perspex.UnitTests;
|
|
using Xunit;
|
|
|
|
namespace Perspex.Markup.Xaml.UnitTests.Xaml
|
|
{
|
|
public class BasicTests
|
|
{
|
|
[Fact]
|
|
public void Named_Control_Is_Added_To_NameScope()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow))
|
|
{
|
|
var xaml = @"
|
|
<Window xmlns='https://github.com/perspex'
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
|
<Button Name='button'>Foo</Button>
|
|
</Window>";
|
|
var loader = new PerspexXamlLoader();
|
|
var window = (Window)loader.Load(xaml);
|
|
var button = window.FindControl<Button>("button");
|
|
|
|
Assert.Equal("Foo", button.Content);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Control_Is_Added_To_Parent_Before_Properties_Are_Set()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow))
|
|
{
|
|
var xaml = @"
|
|
<Window xmlns='https://github.com/perspex'
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
|
xmlns:local='clr-namespace:Perspex.Markup.Xaml.UnitTests.Xaml;assembly=Perspex.Markup.Xaml.UnitTests'>
|
|
<local:InitializationOrderTracker Width='100'/>
|
|
</Window>";
|
|
var loader = new PerspexXamlLoader();
|
|
var window = (Window)loader.Load(xaml);
|
|
var tracker = (InitializationOrderTracker)window.Content;
|
|
|
|
var attached = tracker.Order.IndexOf("AttachedToLogicalTree");
|
|
var widthChanged = tracker.Order.IndexOf("Property Width Changed");
|
|
|
|
Assert.NotEqual(-1, attached);
|
|
Assert.NotEqual(-1, widthChanged);
|
|
Assert.True(attached < widthChanged);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|