/// <summary> /// Handler for selection change event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="SelectionChangedEventArgs"/> instance containing the event data.</param> private void TestSelectionChanged(object sender, SelectionChangedEventArgs e) { if (TestsTreeView.SelectedItems.Count == 1 && TestsTreeView.SelectedItems[0] is TestMethod) { var testMethod = TestsTreeView.SelectedItems[0] as TestMethod; TestResult = new TestResultsViewModel(testMethod.Name, testMethod.ExecutionResult, null); } else { dynamic groupedTests = Tests.SelectMany(t => t.TestMethods) .GroupBy(t => t.ExecutionResult.Status) .Select(t => new { Status = t.Key, Count = t.Count() }) .Where(t => t.Count > 0); TestResult = new TestResultsViewModel("Summary", null, groupedTests); } }