using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.UnitTests;
using Avalonia.VisualTree;
using Xunit;
namespace Avalonia.Markup.Xaml.UnitTests.Xaml
{
public class ControlThemeTests : XamlTestBase
{
[Fact]
public void ControlTheme_Can_Be_StaticResource()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = $@"
{ControlThemeXaml}
";
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
var button = Assert.IsType(window.Content);
window.LayoutManager.ExecuteInitialLayoutPass();
Assert.NotNull(button.Template);
var child = Assert.Single(button.GetVisualChildren());
var border = Assert.IsType(child);
Assert.Equal(Brushes.Red, border.Background);
}
}
[Fact]
public void ControlTheme_Can_Be_Set_In_Style()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = $@"
{ControlThemeXaml}
";
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
var button = Assert.IsType(window.Content);
window.LayoutManager.ExecuteInitialLayoutPass();
Assert.NotNull(button.Template);
var child = Assert.Single(button.GetVisualChildren());
var border = Assert.IsType(child);
Assert.Equal(Brushes.Red, border.Background);
}
}
private const string ControlThemeXaml = @"
";
}
}