public void ParentChanged_Attached_Methods_Should_Be_Called_In_Right_Order() { var target = new TestRoot(); var child = new TestVisual(); int changed = 0; int attched = 0; int i = 1; child.VisualParentChangedCalled += (s, e) => changed = i++; child.AttachedToVisualTreeCalled += (s, e) => attched = i++; target.AddChild(child); Assert.Equal(1, changed); Assert.Equal(2, attched); }
public void Adding_Children_Should_Fire_OnAttachedToVisualTree() { var child2 = new TestVisual(); var child1 = new TestVisual { Child = child2 }; var root = new TestRoot(); var called1 = false; var called2 = false; child1.AttachedToVisualTree += (s, e) => called1 = true; child2.AttachedToVisualTree += (s, e) => called2 = true; root.Child = child1; Assert.True(called1); Assert.True(called2); }
public void ParentChanged_Detached_Methods_Should_Be_Called_In_Right_Order() { var target = new TestRoot(); var child = new TestVisual(); int changed = 0; int detached = 0; int i = 1; target.AddChild(child); child.VisualParentChangedCalled += (s, e) => changed = i++; child.DetachedFromVisualTreeCalled += (s, e) => detached = i++; target.ClearChildren(); Assert.Equal(1, changed); Assert.Equal(2, detached); }
public void Removing_Children_Should_Fire_OnDetachedFromVisualTree() { var child2 = new TestVisual(); var child1 = new TestVisual { Child = child2 }; var root = new TestRoot(); var called1 = false; var called2 = false; root.Child = child1; child1.DetachedFromVisualTree += (s, e) => called1 = true; child2.DetachedFromVisualTree += (s, e) => called2 = true; root.Child = null; Assert.True(called1); Assert.True(called2); }
public void Controls_Should_Remove_Themselves_From_NameScopes_In_Attached_Property() { var child2 = new TestVisual { Name = "bar" }; var child1 = new TestVisual { Name = "foo", Child = child2,[NameScope.NameScopeProperty] = new NameScope() }; var root = new TestRoot { Child = child1 }; root.Child = null; Assert.Null(root.Find("foo")); Assert.Null(root.Find("bar")); Assert.Null(NameScope.GetNameScope(child1).Find("bar")); }
public void Controls_Should_Remove_Themselves_From_Root_NameScope() { var child2 = new TestVisual { Name = "bar" }; var child1 = new TestVisual { Name = "foo", Child = child2 }; var root = new TestRoot { Child = child1 }; root.Child = null; Assert.Null(root.Find("foo")); Assert.Null(root.Find("bar")); }
public void Controls_Should_Add_Themselves_To_NameScopes_In_Attached_Property() { var child2 = new TestVisual { Name = "bar", [NameScope.NameScopeProperty] = new NameScope() }; var child1 = new TestVisual { Name = "foo", Child = child2}; var root = new TestRoot { Child = child1 }; Assert.Same(child1, root.Find("foo")); Assert.Null(root.Find("bar")); Assert.Same(child2, NameScope.GetNameScope(child2).Find("bar")); }
public void Controls_Should_Add_Themselves_To_Root_NameScope() { var child2 = new TestVisual { Name = "bar" }; var child1 = new TestVisual { Name = "foo", Child = child2 }; var root = new TestRoot { Child = child1 }; Assert.Same(child1, root.Find("foo")); Assert.Same(child2, root.Find("bar")); }