public void GetSelfAndChildren_WhenNoChildren_ReturnsOnlySelf() { var s = new Child(); CollectionAssert.AreEqual( new[] { s }, ScreenTreeHelper.GetChildrenOf(s, includeSelf: true).ToArray() ); }
public void GetSelfAndChildren_WithChildren_ReturnsSelfAndChildren() { var p = new Parent(); var c = new Child(); p.Children.Attach(c); var result = ScreenTreeHelper.GetChildrenOf(p, includeSelf: true).ToArray(); CollectionAssert.Contains(result, p); CollectionAssert.Contains(result, c); }
public void GetSelfAndChildren_WithGrandchildren_ReturnsSelfAndChildrenOnly() { var p = new Parent(); var child = new Parent(); var grand = new Child(); p.Children.Attach(child); child.Children.Attach(grand); var result = ScreenTreeHelper.GetChildrenOf(p, includeSelf: true).ToArray(); CollectionAssert.Contains(result, p); CollectionAssert.Contains(result, child); CollectionAssert.DoesNotContain(result, grand); }
public void GetDescendantsOfWithoutSelf_ReturnsChildrenAndGrandchildren() { var p = new Parent(); var child = new Parent(); var grand = new Child(); p.Children.Attach(child); child.Children.Attach(grand); var result = ScreenTreeHelper.GetDescendantsOf(p, includeSelf: false); CollectionAssert.AreEqual( new IScreenBase[] { child, grand }, result.ToArray() ); }
public Window GetAssociatedWindow(IScreenBase screen) { if (screen == null) { return(null); } WindowLifecycle lf = ScreenTreeHelper .GetAncestorsOf(screen, includeSelf: true) .SelectMany(s => s.Children.OfType <WindowLifecycle>()) .FirstOrDefault(); if (lf != null) { return(lf.Window); } throw new ArgumentException(ExceptionTexts.NoAssociatedWindow); }