public void TestBringToFront() { // Create this: // // Root // |- Child 1 // |- Child 2 // |- Child 2 Child 1 // |- Child 2 Child 2 Control root = new Control(); Control child1 = new Control(); Control child2 = new Control(); Control child2Child1 = new Control(); Control child2Child2 = new Control(); root.Children.Add(child1); root.Children.Add(child2); child2.Children.Add(child2Child1); child2.Children.Add(child2Child2); // The second child of each control should not be on top Assert.AreNotSame(child2, root.Children[0]); Assert.AreNotSame(child2Child2, child2.Children[0]); // Bring the control to the top. This should recursively move its parents // to the top of the siblings so the control ends up in the foreground. child2Child2.BringToFront(); // Make sure the control and its parent are the first one in each list Assert.AreSame(child2, root.Children[0]); Assert.AreSame(child2Child2, child2.Children[0]); }
public void TestMoveToEnd() { Control parent = new Control(); Control child1 = new Control(); Control child2 = new Control(); Control child3 = new Control(); parent.Children.Add(child1); parent.Children.Add(child2); parent.Children.Add(child3); Assert.AreSame(child1, parent.Children[0]); Assert.AreSame(child2, parent.Children[1]); Assert.AreSame(child3, parent.Children[2]); child3.BringToFront(); Assert.AreSame(child3, parent.Children[0]); Assert.AreSame(child1, parent.Children[1]); Assert.AreSame(child2, parent.Children[2]); }