public void FindParentControl_ParentDoesNotExists() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); StackPanel intermediateStackPanel = visual.IntermediatePanel; TabControl g = intermediateStackPanel.FindParentControl<TabControl>(); Assert.IsNull(g); }); }
public void FindParentControl_ParentExists() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); StackPanel intermediateStackPanel = visual.IntermediatePanel; StackPanel sp = intermediateStackPanel.FindParentControl<StackPanel>(); Assert.IsTrue(sp != null && sp.Name == "RootPanel"); }); }
public void FindChildControl_IndexTooGreat() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); TextBox tb = visual.FindChildControl<TextBox>(4); Assert.IsNull(tb); }); }
public void FindChildControl_IndexLessThanZero() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); TextBox tb = visual.FindChildControl<TextBox>(-1); Assert.IsTrue(tb != null && tb.Text == "TextBox 1"); }); }
public void FindChildControl_FindNonExistentControl() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); //Attempt to find first, implicit TabControl tc = visual.FindChildControl<TabControl>(); Assert.IsNull(tc); //Attempt to find first, explicit tc = visual.FindChildControl<TabControl>(0); Assert.IsNull(tc); //Attempt to find other than first tc = visual.FindChildControl<TabControl>(2); Assert.IsNull(tc); }); }
public void FindChildControl_FindFirst() { ThreadRunner.RunInSTA(delegate { DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual(); RenderUtility.RenderVisual(visual); //Assume first element TextBox tb = visual.FindChildControl<TextBox>(); Assert.IsTrue(tb != null && tb.Text == "TextBox 1"); //Explicitly findfirst element tb = visual.FindChildControl<TextBox>(0); Assert.IsTrue(tb != null && tb.Text == "TextBox 1"); }); }