@@ -78,6 +78,8 @@ public TestExplorerViewModel(ISelectionService selectionService,
78
78
UnignoreTestCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteUnignoreTestCommand ) ;
79
79
IgnoreGroupCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteIgnoreGroupCommand , CanIgnoreGroupCommand ) ;
80
80
UnignoreGroupCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteUnignoreGroupCommand , CanUnignoreGroupCommand ) ;
81
+ IgnoreSelectedTestsCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteIgnoreSelectedTestsCommand , CanExecuteSelectedTestsCommand ) ;
82
+ UnignoreSelectedTestsCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteUnignoreSelectedTestsCommand , CanUnignoreSelectedTestsCommand ) ;
81
83
82
84
RewritingManager = rewritingManager ;
83
85
AnnotationUpdater = annotationUpdater ;
@@ -259,7 +261,7 @@ public bool DisplayUnignoreGroupLabel
259
261
260
262
var testsInGroup = MouseOverGroup . Items . Cast < TestMethodViewModel > ( ) ;
261
263
262
- return testsInGroup . Where ( test => test . Method . IsIgnored ) . Any ( ) ; ;
264
+ return testsInGroup . Any ( test => test . Method . IsIgnored ) ;
263
265
}
264
266
}
265
267
@@ -274,7 +276,7 @@ public bool DisplayIgnoreGroupLabel
274
276
275
277
var testsInGroup = MouseOverGroup . Items . Cast < TestMethodViewModel > ( ) ;
276
278
277
- return testsInGroup . Where ( test => test . Method . IsIgnored ) . Count ( ) != MouseOverGroup . Items . Count ;
279
+ return testsInGroup . Count ( test => test . Method . IsIgnored ) != MouseOverGroup . ItemCount ;
278
280
}
279
281
}
280
282
@@ -315,6 +317,9 @@ public bool DisplayIgnoreGroupLabel
315
317
public CommandBase IgnoreGroupCommand { get ; }
316
318
public CommandBase UnignoreGroupCommand { get ; }
317
319
320
+ public CommandBase IgnoreSelectedTestsCommand { get ; }
321
+ public CommandBase UnignoreSelectedTestsCommand { get ; }
322
+
318
323
#endregion
319
324
320
325
#region Delegates
@@ -329,6 +334,11 @@ private bool CanExecuteSelectedTestsCommand(object obj)
329
334
return ! Model . IsBusy && obj is IList viewModels && viewModels . Count > 0 ;
330
335
}
331
336
337
+ private bool CanUnignoreSelectedTestsCommand ( object obj )
338
+ {
339
+ return true ;
340
+ }
341
+
332
342
private bool CanExecuteGroupCommand ( object obj )
333
343
{
334
344
return ! Model . IsBusy && ( MouseOverTest != null || MouseOverGroup != null ) ;
@@ -432,22 +442,27 @@ private void ExecuteIgnoreTestCommand(object parameter)
432
442
{
433
443
var rewriteSession = RewritingManager . CheckOutCodePaneSession ( ) ;
434
444
435
- AnnotationUpdater . AddAnnotation ( rewriteSession , _mousedOverTestMethod . Declaration , new IgnoreTestAnnotation ( ) ) ;
445
+ var testMethod = parameter is null
446
+ ? _mousedOverTestMethod
447
+ : ( TestMethod ) parameter ;
448
+
449
+ AnnotationUpdater . AddAnnotation ( rewriteSession , testMethod . Declaration , new IgnoreTestAnnotation ( ) ) ;
436
450
437
451
rewriteSession . TryRewrite ( ) ;
438
452
}
439
453
440
454
private void ExecuteUnignoreTestCommand ( object parameter )
441
455
{
442
- var rewriteSession = RewritingManager . CheckOutCodePaneSession ( ) ;
443
-
444
- var ignoreTestAnnotations = _mousedOverTestMethod . Declaration . Annotations
456
+ var testMethod = parameter is null
457
+ ? _mousedOverTestMethod
458
+ : ( TestMethod ) parameter ;
459
+
460
+ var ignoreTestAnnotations = testMethod . Declaration . Annotations
445
461
. Where ( pta => pta . Annotation is IgnoreTestAnnotation ) ;
446
462
447
- foreach ( var ignoreTestAnnotation in ignoreTestAnnotations )
448
- {
449
- AnnotationUpdater . RemoveAnnotation ( rewriteSession , ignoreTestAnnotation ) ;
450
- }
463
+ var rewriteSession = RewritingManager . CheckOutCodePaneSession ( ) ;
464
+
465
+ AnnotationUpdater . RemoveAnnotations ( rewriteSession , ignoreTestAnnotations ) ;
451
466
452
467
rewriteSession . TryRewrite ( ) ;
453
468
}
@@ -460,20 +475,6 @@ private void ExecuteIgnoreGroupCommand (object parameter)
460
475
461
476
foreach ( TestMethodViewModel test in testGroup . Items )
462
477
{
463
- //var needsIgnoreAnnotationAdded = true;
464
- //foreach (var annotation in test.Method.Declaration.Annotations)
465
- //{
466
- // if (annotation.Annotation is IgnoreTestAnnotation)
467
- // {
468
- // needsIgnoreAnnotationAdded = false;
469
- // };
470
- //}
471
-
472
- //if (needsIgnoreAnnotationAdded)
473
- //{
474
- // AnnotationUpdater.AddAnnotation(rewriteSession, test.Method.Declaration, ignoreTestAnnotation);
475
- //}
476
-
477
478
if ( ! test . Method . IsIgnored )
478
479
{
479
480
AnnotationUpdater . AddAnnotation ( rewriteSession , test . Method . Declaration , ignoreTestAnnotation ) ;
@@ -502,6 +503,60 @@ private void ExecuteUnignoreGroupCommand(object parameter)
502
503
rewriteSession . TryRewrite ( ) ;
503
504
}
504
505
506
+ private void ExecuteUnignoreSelectedTestsCommand ( object parameter )
507
+ {
508
+ if ( Model . IsBusy || ! ( parameter is IList viewModels && viewModels . Count > 0 ) )
509
+ {
510
+ return ;
511
+ }
512
+
513
+ var ignoredModels = viewModels . OfType < TestMethodViewModel > ( )
514
+ . Where ( model => model . Method . IsIgnored ) ;
515
+
516
+ if ( ! ignoredModels . Any ( ) )
517
+ {
518
+ return ;
519
+ }
520
+
521
+ var rewriteSession = RewritingManager . CheckOutCodePaneSession ( ) ;
522
+
523
+ foreach ( var test in ignoredModels )
524
+ {
525
+ var ignoreTestAnnotations = test . Method . Declaration . Annotations
526
+ . Where ( pta => pta . Annotation is IgnoreTestAnnotation ) ;
527
+
528
+ AnnotationUpdater . RemoveAnnotations ( rewriteSession , ignoreTestAnnotations ) ;
529
+ }
530
+
531
+ rewriteSession . TryRewrite ( ) ;
532
+ }
533
+
534
+ private void ExecuteIgnoreSelectedTestsCommand ( object parameter )
535
+ {
536
+ if ( Model . IsBusy || ! ( parameter is IList viewModels && viewModels . Count > 0 ) )
537
+ {
538
+ return ;
539
+ }
540
+
541
+ var unignoredModels = viewModels . OfType < TestMethodViewModel > ( )
542
+ . Where ( model => ! model . Method . IsIgnored ) ;
543
+
544
+ if ( ! unignoredModels . Any ( ) )
545
+ {
546
+ return ;
547
+ }
548
+
549
+ var rewriteSession = RewritingManager . CheckOutCodePaneSession ( ) ;
550
+ var ignoreTestAnnotation = new IgnoreTestAnnotation ( ) ;
551
+
552
+ foreach ( var test in unignoredModels )
553
+ {
554
+ AnnotationUpdater . AddAnnotation ( rewriteSession , test . Method . Declaration , ignoreTestAnnotation ) ;
555
+ }
556
+
557
+ rewriteSession . TryRewrite ( ) ;
558
+ }
559
+
505
560
private void ExecuteCopyResultsCommand ( object parameter )
506
561
{
507
562
const string XML_SPREADSHEET_DATA_FORMAT = "XML Spreadsheet" ;
0 commit comments