Skip to content

Commit 9598b1e

Browse files
committed
Add (Un|I)gnoreSelectedGroupCommand to context menu
1 parent 80948b8 commit 9598b1e

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
<BitmapImage x:Key="IgnoreTestImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/flask-empty.png" />
5858
<BitmapImage x:Key="UnignoreTestImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/flask-undo.png" />
5959

60+
<BitmapImage x:Key="IgnoreTestGroupImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/flask-empty.png" />
61+
<BitmapImage x:Key="UnignoreTestGroupImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/flask-undo.png" />
62+
6063
<local:TestOutcomeImageSourceConverter x:Key="OutcomeIconConverter" />
6164
<converters:MillisecondToTimeMagnitudeConverter x:Key="FormattedTime" />
6265
<converters:InvertBoolValueConverter x:Key="InvertBoolValue" />
@@ -451,6 +454,18 @@
451454
<Image Source="{StaticResource UnignoreTestImage}" />
452455
</MenuItem.Icon>
453456
</MenuItem>
457+
<MenuItem Command="{Binding IgnoreSelectedGroupCommand}"
458+
Header="{Resx ResxName=Rubberduck.Resources.UnitTesting.TestExplorer, Key=TestExplorer_ContextMenuIgnoreGroup}">
459+
<MenuItem.Icon>
460+
<Image Source="{StaticResource IgnoreTestGroupImage}" />
461+
</MenuItem.Icon>
462+
</MenuItem>
463+
<MenuItem Command="{Binding UnignoreSelectedGroupCommand}"
464+
Header="{Resx ResxName=Rubberduck.Resources.UnitTesting.TestExplorer, Key=TestExplorer_ContextMenuUnignoreGroup}">
465+
<MenuItem.Icon>
466+
<Image Source="{StaticResource UnignoreTestGroupImage}" />
467+
</MenuItem.Icon>
468+
</MenuItem>
454469
</ContextMenu>
455470
</DataGrid.ContextMenu>
456471
<i:Interaction.Behaviors>

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public TestExplorerViewModel(ISelectionService selectionService,
7373
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);
7474
IgnoreTestCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteIgnoreTestCommand);
7575
UnignoreTestCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUnignoreTestCommand);
76+
IgnoreSelectedGroupCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteIgnoreGroupCommand, CanIgnoreSelectedGroupCommand);
77+
UnignoreSelectedGroupCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUnignoreGroupCommand, CanUnignoreSelectedGroupCommand);
7678

7779
RewritingManager = rewritingManager;
7880
AnnotationUpdater = annotationUpdater;
@@ -275,6 +277,9 @@ private void HandleTestCompletion(object sender, TestCompletedEventArgs e)
275277
public CommandBase IgnoreTestCommand { get; }
276278
public CommandBase UnignoreTestCommand { get; }
277279

280+
public CommandBase IgnoreSelectedGroupCommand { get; }
281+
public CommandBase UnignoreSelectedGroupCommand { get; }
282+
278283
#endregion
279284

280285
#region Delegates
@@ -294,6 +299,16 @@ private bool CanExecuteSelectedGroupCommand(object obj)
294299
return !Model.IsBusy && (MouseOverTest != null || MouseOverGroup != null);
295300
}
296301

302+
private bool CanIgnoreSelectedGroupCommand(object obj)
303+
{
304+
return CanExecuteSelectedGroupCommand(obj);
305+
}
306+
307+
private bool CanUnignoreSelectedGroupCommand(object obj)
308+
{
309+
return CanExecuteSelectedGroupCommand(obj);
310+
}
311+
297312
private bool CanExecuteResetResultsCommand(object obj)
298313
{
299314
return !Model.IsBusy && Tests.OfType<TestMethodViewModel>().Any(test => test.Result.Outcome != TestOutcome.Unknown);
@@ -374,15 +389,24 @@ private void ExecuteIgnoreTestCommand(object parameter)
374389
{
375390
var rewriteSession = RewritingManager.CheckOutCodePaneSession();
376391

377-
AnnotationUpdater.AddAnnotation(rewriteSession, _mousedOverTestMethod.Declaration, Parsing.Annotations.AnnotationType.IgnoreTest);
392+
var testMethod = parameter == null
393+
? _mousedOverTestMethod
394+
: (parameter as TestMethodViewModel).Method;
395+
396+
AnnotationUpdater.AddAnnotation(rewriteSession, testMethod.Declaration, Parsing.Annotations.AnnotationType.IgnoreTest);
378397

379398
rewriteSession.TryRewrite();
380399
}
381400

382401
private void ExecuteUnignoreTestCommand(object parameter)
383402
{
384403
var rewriteSession = RewritingManager.CheckOutCodePaneSession();
385-
var ignoreTestAnnotations = _mousedOverTestMethod.Declaration.Annotations
404+
405+
var testMethod = parameter == null
406+
? _mousedOverTestMethod
407+
: (parameter as TestMethodViewModel).Method;
408+
409+
var ignoreTestAnnotations = testMethod.Declaration.Annotations
386410
.Where(iannotations => iannotations.AnnotationType == Parsing.Annotations.AnnotationType.IgnoreTest);
387411

388412
foreach (var ignoreTestAnnotation in ignoreTestAnnotations)
@@ -393,6 +417,22 @@ private void ExecuteUnignoreTestCommand(object parameter)
393417
rewriteSession.TryRewrite();
394418
}
395419

420+
private void ExecuteIgnoreGroupCommand (object parameter)
421+
{
422+
foreach (TestMethodViewModel test in _mouseOverGroup.Items)
423+
{
424+
ExecuteIgnoreTestCommand(test);
425+
}
426+
}
427+
428+
private void ExecuteUnignoreGroupCommand(object parameter)
429+
{
430+
foreach (TestMethodViewModel test in _mouseOverGroup.Items)
431+
{
432+
ExecuteUnignoreTestCommand(test);
433+
}
434+
}
435+
396436
private void ExecuteCopyResultsCommand(object parameter)
397437
{
398438
const string XML_SPREADSHEET_DATA_FORMAT = "XML Spreadsheet";

Rubberduck.Resources/UnitTesting/TestExplorer.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/UnitTesting/TestExplorer.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,10 @@
351351
<data name="TestExplorer_TestToggle_Unignore" xml:space="preserve">
352352
<value>Unignore test</value>
353353
</data>
354+
<data name="TestExplorer_ContextMenuIgnoreGroup" xml:space="preserve">
355+
<value>Ignore all tests in group</value>
356+
</data>
357+
<data name="TestExplorer_ContextMenuUnignoreGroup" xml:space="preserve">
358+
<value>Unignore all tests in group</value>
359+
</data>
354360
</root>

0 commit comments

Comments
 (0)