@@ -18,6 +18,7 @@ namespace Rubberduck.UI.UnitTesting
18
18
{
19
19
public class TestExplorerViewModel : ViewModelBase , INavigateSelection , IDisposable
20
20
{
21
+ private readonly VBE _vbe ;
21
22
private readonly RubberduckParserState _state ;
22
23
private readonly ITestEngine _testEngine ;
23
24
private readonly TestExplorerModel _model ;
@@ -35,6 +36,7 @@ public TestExplorerViewModel(VBE vbe,
35
36
IGeneralConfigService configService ,
36
37
IOperatingSystem operatingSystem )
37
38
{
39
+ _vbe = vbe ;
38
40
_state = state ;
39
41
_testEngine = testEngine ;
40
42
_testEngine . TestCompleted += TestEngineTestCompleted ;
@@ -45,7 +47,7 @@ public TestExplorerViewModel(VBE vbe,
45
47
46
48
_navigateCommand = new NavigateCommand ( ) ;
47
49
48
- _runAllTestsCommand = new RunAllTestsCommand ( state , testEngine , model ) ;
50
+ _runAllTestsCommand = new RunAllTestsCommand ( vbe , state , testEngine , model ) ;
49
51
_runAllTestsCommand . RunCompleted += RunCompleted ;
50
52
51
53
_addTestModuleCommand = new AddTestModuleCommand ( vbe , state , newTestModuleCommand ) ;
@@ -83,22 +85,26 @@ private void RunCompleted(object sender, TestRunEventArgs e)
83
85
84
86
private bool CanExecuteRunPassedTestsCommand ( object obj )
85
87
{
86
- return _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Succeeded ) ;
88
+ return _vbe . VBProjects . Cast < VBProject > ( ) . All ( project => project . Mode == vbext_VBAMode . vbext_vm_Design ) &&
89
+ _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Succeeded ) ;
87
90
}
88
91
89
92
private bool CanExecuteRunFailedTestsCommand ( object obj )
90
93
{
91
- return _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Failed ) ;
94
+ return _vbe . VBProjects . Cast < VBProject > ( ) . All ( project => project . Mode == vbext_VBAMode . vbext_vm_Design ) &&
95
+ _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Failed ) ;
92
96
}
93
97
94
98
private bool CanExecuteRunNotExecutedTestsCommand ( object obj )
95
99
{
96
- return _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Unknown ) ;
100
+ return _vbe . VBProjects . Cast < VBProject > ( ) . All ( project => project . Mode == vbext_VBAMode . vbext_vm_Design ) &&
101
+ _model . Tests . Any ( test => test . Result . Outcome == TestOutcome . Unknown ) ;
97
102
}
98
103
99
104
private bool CanExecuteRepeatLastRunCommand ( object obj )
100
105
{
101
- return _model . LastRun . Any ( ) ;
106
+ return _vbe . VBProjects . Cast < VBProject > ( ) . All ( project => project . Mode == vbext_VBAMode . vbext_vm_Design ) &&
107
+ _model . LastRun . Any ( ) ;
102
108
}
103
109
104
110
public event EventHandler < EventArgs > TestCompleted ;
0 commit comments