Skip to content

Commit 537a781

Browse files
committed
Fix NRE in TestExplorerViewModel
The root problem is that the affected command did not consider that there might be no selection.
1 parent 3b7b5b8 commit 537a781

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public bool CanExecuteIgnoreSelectedTests(object obj)
256256

257257
return false;
258258
}
259+
259260
public bool CanExecuteUnignoreSelectedTests(object obj)
260261
{
261262
if (!Model.IsBusy && obj is IList viewModels && viewModels.Count > 0)
@@ -273,12 +274,14 @@ public bool CanExecuteIgnoreGroupCommand(object obj)
273274

274275
return groupItems.Cast<TestMethodViewModel>().Count(test => test.Method.IsIgnored) != groupItems.Count;
275276
}
277+
276278
public bool CanExecuteUnignoreGroupCommand(object obj)
277279
{
278280
var groupItems = MouseOverGroup?.Items
279-
?? GroupContainingSelectedTest(MouseOverTest).Items;
280-
281-
return groupItems.Cast<TestMethodViewModel>().Any(test => test.Method.IsIgnored);
281+
?? GroupContainingSelectedTest(MouseOverTest)?.Items;
282+
283+
return groupItems != null
284+
&& groupItems.Cast<TestMethodViewModel>().Any(test => test.Method.IsIgnored);
282285
}
283286

284287
#region Commands

0 commit comments

Comments
 (0)