Browse Source

Add failing test for clearing templated child's parent.

pull/1711/head
Steven Kirk 8 years ago
parent
commit
9ccf63d51b
  1. 18
      tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs

18
tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs

@ -160,6 +160,24 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.Equal(target, child.GetLogicalParent()); Assert.Equal(target, child.GetLogicalParent());
} }
[Fact]
public void Changing_Template_Should_Clear_Old_Templated_Childs_Parent()
{
var target = new TemplatedControl
{
Template = new FuncControlTemplate(_ => new Decorator())
};
target.ApplyTemplate();
var child = (Decorator)target.GetVisualChildren().Single();
target.Template = new FuncControlTemplate(_ => new Canvas());
target.ApplyTemplate();
Assert.Null(child.Parent);
}
[Fact] [Fact]
public void Nested_Templated_Control_Should_Not_Have_Template_Applied() public void Nested_Templated_Control_Should_Not_Have_Template_Applied()
{ {

Loading…
Cancel
Save