Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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_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());
        }
Exemplo n.º 10
0
        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());
        }
Exemplo n.º 11
0
        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());
        }
Exemplo n.º 12
0
        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());
        }
Exemplo n.º 13
0
        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());
        }
Exemplo n.º 14
0
        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());
        }
Exemplo n.º 15
0
        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());
        }
Exemplo n.º 16
0
        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());
        }
Exemplo n.º 17
0
        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());
        }
Exemplo n.º 18
0
        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());
        }
Exemplo n.º 19
0
        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());
        }
Exemplo n.º 20
0
        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());
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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());
        }
Exemplo n.º 23
0
        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());
        }