public void FindDescendantsForNullParamTest() { // Act & Verify Assert.ThrowsException <ArgumentException>(() => { var descendants = VisualTreeHelperExtensions .FindDescendants <Panel>(null) .ToList(); }); }
/// <summary> /// Plays the moving coin animation. /// </summary> public void PlayMovingCoinAnimation() { var rootGrid = VisualTreeHelperExtensions.FindDescendants <Grid>(this) .FirstOrDefault(g => g.Name == "RootGrid"); if (rootGrid != null) { var animation = (Storyboard)rootGrid.Resources["movingCoinAnimation"]; animation.Begin(); } }
public void FindDescendantsForOnlyParentElementTest() { // Arrange var grid = new Grid(); // Act var descendants = VisualTreeHelperExtensions .FindDescendants <Panel>(grid) .ToList(); // Verify Assert.IsNotNull(descendants); Assert.AreEqual(1, descendants.Count); Assert.AreEqual(grid, descendants.First()); }
public void FindDescendantsTest() { // Arrange var grid = new Grid(); var grid2 = new Grid(); grid.Children.Add(grid2); // Act var descendants = VisualTreeHelperExtensions .FindDescendants <Panel>(grid) .ToList(); // Verify Assert.IsNotNull(descendants); Assert.AreEqual(2, descendants.Count); Assert.AreEqual(grid, descendants.First()); Assert.AreEqual(grid2, descendants.Skip(1).First()); }