public void Adding_Control_To_Panel_Should_Set_Child_Controls_Parent() { var panel = new Panel(); var child = new Control(); panel.Children.Add(child); Assert.Equal(child.Parent, panel); Assert.Equal(child.GetLogicalParent(), panel); }
public void Setting_Controls_Should_Set_Child_Controls_Parent() { var panel = new Panel(); var child = new Control(); panel.Children = new Controls { child }; Assert.Equal(child.Parent, panel); Assert.Equal(child.GetLogicalParent(), panel); }
public void Removing_Control_From_Panel_Should_Clear_Child_Controls_Parent() { var panel = new Panel(); var child = new Control(); panel.Children.Add(child); panel.Children.Remove(child); Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); }
public void Control_Item_Should_Be_Logical_Child_Before_ApplyTemplate() { var target = new ItemsControl(); var child = new Control(); target.Template = GetTemplate(); target.Items = new[] { child }; Assert.Equal(child.Parent, target); Assert.Equal(child.GetLogicalParent(), target); Assert.Equal(new[] { child }, target.GetLogicalChildren()); }
public void Clearing_Content_Should_Clear_Logical_Child() { var target = new HeaderedItemsControl(); var child = new Control(); target.Header = child; target.Header = null; Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); Assert.Empty(target.GetLogicalChildren()); }
public void Clearing_Content_Clear_Childs_Parent() { var target = new ContentPresenter(); var child = new Control(); target.Content = child; target.ApplyTemplate(); target.Content = null; target.ApplyTemplate(); Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); }
public void Control_Content_Should_Be_Logical_Child_Before_ApplyTemplate() { var target = new ContentControl { Template = GetTemplate(), }; var child = new Control(); target.Content = child; Assert.Equal(child.Parent, target); Assert.Equal(child.GetLogicalParent(), target); Assert.Equal(new[] { child }, target.GetLogicalChildren()); }
public void Control_Item_Should_Be_Removed_From_Logical_Children_Before_ApplyTemplate() { var target = new ItemsControl(); var child = new Control(); var items = new PerspexList<Control>(child); target.Template = GetTemplate(); target.Items = items; items.RemoveAt(0); Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); Assert.Empty(target.GetLogicalChildren()); }
public void Control_Item_Should_Be_Removed_From_Logical_Children_Before_ApplyTemplate() { var target = new ItemsControl(); var child = new Control(); var items = new AvaloniaList <Control>(child); target.Template = GetTemplate(); target.Items = items; items.RemoveAt(0); Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); Assert.Empty(target.GetLogicalChildren()); }
public void Control_Header_Should_Be_Logical_Child_Before_ApplyTemplate() { var target = new HeaderedItemsControl { Template = GetTemplate(), }; var child = new Control(); target.Header = child; Assert.Equal(child.Parent, target); Assert.Equal(child.GetLogicalParent(), target); Assert.Equal(new[] { child }, target.GetLogicalChildren()); }
public void Clearing_Content_Should_Clear_Logical_Child() { var target = new ContentControl(); var child = new Control(); target.Content = child; Assert.Equal(new[] { child }, target.GetLogicalChildren()); target.Content = null; Assert.Null(child.Parent); Assert.Null(child.GetLogicalParent()); Assert.Empty(target.GetLogicalChildren()); }
public void Resetting_Panel_Children_Should_Clear_Child_Controls_Parent() { var panel = new Panel(); var child1 = new Control(); var child2 = new Control(); panel.Children.Add(child1); panel.Children.Add(child2); panel.Children = new Controls(); Assert.Null(child1.Parent); Assert.Null(child1.GetLogicalParent()); Assert.Null(child2.Parent); Assert.Null(child2.GetLogicalParent()); }
public void Replacing_Panel_Children_Should_Clear_And_Set_Control_Parent() { var panel = new Panel(); var child1 = new Control(); var child2 = new Control(); panel.Children.Add(child1); panel.Children[0] = child2; Assert.Null(child1.Parent); Assert.Null(child1.GetLogicalParent()); Assert.Null(child1.GetVisualParent()); Assert.Same(child2.Parent, panel); Assert.Same(child2.GetLogicalParent(), panel); Assert.Same(child2.GetVisualParent(), panel); }
public void Control_Content_Should_Be_Logical_Child_After_ApplyTemplate() { var target = new ContentControl { Template = GetTemplate(), }; var child = new Control(); target.Content = child; target.ApplyTemplate(); ((ContentPresenter)target.Presenter).UpdateChild(); Assert.Equal(child.Parent, target); Assert.Equal(child.GetLogicalParent(), target); Assert.Equal(new[] { child }, target.GetLogicalChildren()); }