33using System ;
44using System . Collections . Specialized ;
55using System . ComponentModel ;
6+ using System . Globalization ;
67using System . Linq ;
8+ using System . Windows . Data ;
9+ using System . Windows ;
710using System . Windows . Input ;
811using System . Windows . Media ;
912
@@ -20,6 +23,7 @@ public class TestExplorerViewModel : ITestResultReporter, INotifyPropertyChanged
2023 public event EventHandler < RunTestsEventArgs > RunTests ;
2124 //public event EventHandler CancelTestRun;
2225 public event EventHandler < GetTestClassInfoEventArgs > GetTestClassInfo ;
26+ public event EventHandler < TestItem > GotoSource ;
2327
2428 public TestExplorerViewModel ( )
2529 {
@@ -29,6 +33,8 @@ public TestExplorerViewModel()
2933 TestItems = new TestClassInfoTestItems ( ) ;
3034 RefreshCommand = new RelayCommand ( Refresh ) ;
3135 CommitCommand = new RelayCommand ( Commit ) ;
36+ ShowTestResultDetailCommand = new RelayCommand < TestItem > ( ShowTestResultDetail ) ;
37+ GoToSourceCommand = new RelayCommand < TestItem > ( GoToSource ) ;
3238 }
3339
3440 private CheckableItems < TestItem > _testItems ;
@@ -332,16 +338,51 @@ public ImageSource RefreshCommandImageSource
332338
333339 protected void Refresh ( )
334340 {
335- RefreshList ? . Invoke ( this , new CheckableTestItemsEventArgs ( TestItems ) ) ;
341+ try
342+ {
343+ RefreshList ? . Invoke ( this , new CheckableTestItemsEventArgs ( TestItems ) ) ;
344+ }
345+ catch ( Exception ex )
346+ {
347+ UITools . ShowException ( ex ) ;
348+ }
336349 }
337350
338351 protected virtual void Commit ( )
339352 {
340- TestClassList list = new TestClassList ( ) ;
341- list . AddRange ( TestItems . Where ( ti => ti . IsChecked ) . Select ( ti => ( ( TestClassInfoTestItem ) ti ) . TestClassInfo ) ) ;
342- RunTests ? . Invoke ( this , new RunTestsEventArgs ( list ) ) ;
353+ try
354+ {
355+ TestClassList list = new TestClassList ( ) ;
356+ list . AddRange ( TestItems . Where ( ti => ti . IsChecked ) . Select ( ti => ( ( TestClassInfoTestItem ) ti ) . TestClassInfo ) ) ;
357+ RunTests ? . Invoke ( this , new RunTestsEventArgs ( list ) ) ;
358+ }
359+ catch ( Exception ex )
360+ {
361+ UITools . ShowException ( ex ) ;
362+ }
363+ }
364+
365+ public ICommand ShowTestResultDetailCommand { get ; }
366+ protected virtual void ShowTestResultDetail ( TestItem testItem )
367+ {
368+ try
369+ {
370+ var testResultViewModel = new TestResultViewModel ( testItem . TestResult ) ;
371+ var testResultView = new TestResultDetailView ( testResultViewModel ) ;
372+ testResultView . ShowDialog ( ) ;
373+ }
374+ catch ( Exception ex )
375+ {
376+ UITools . ShowException ( ex ) ;
377+ }
378+
343379 }
344380
381+ public ICommand GoToSourceCommand { get ; }
382+ protected virtual void GoToSource ( TestItem testItem )
383+ {
384+ GotoSource ? . Invoke ( this , testItem ) ;
385+ }
345386 }
346387
347388 public static class TestExplorerInfo
0 commit comments