@@ -337,7 +337,7 @@ public void AddMDIForm()
337
337
var vbe = builder . AddProject ( project . Build ( ) ) . Build ( ) ;
338
338
var vbeEvents = MockVbeEvents . CreateMockVbeEvents ( vbe ) ;
339
339
340
- var commands = new List < CommandBase > { new AddMDIFormCommand ( new AddComponentCommand ( vbe . Object ) ) } ;
340
+ var commands = new List < CommandBase > { new AddMDIFormCommand ( vbe . Object , new AddComponentCommand ( vbe . Object ) ) } ;
341
341
342
342
var projectRepository = new ProjectsRepository ( vbe . Object ) ;
343
343
var uiDispatcher = new Mock < IUiDispatcher > ( ) ;
@@ -375,7 +375,7 @@ public bool AddMDIForm_CanExecuteBasedOnProjectType(ProjectType projectType)
375
375
var vbe = builder . AddProject ( project . Build ( ) ) . Build ( ) ;
376
376
var vbeEvents = MockVbeEvents . CreateMockVbeEvents ( vbe ) ;
377
377
378
- var commands = new List < CommandBase > { new AddMDIFormCommand ( new AddComponentCommand ( vbe . Object ) ) } ;
378
+ var commands = new List < CommandBase > { new AddMDIFormCommand ( vbe . Object , new AddComponentCommand ( vbe . Object ) ) } ;
379
379
380
380
var projectRepository = new ProjectsRepository ( vbe . Object ) ;
381
381
var uiDispatcher = new Mock < IUiDispatcher > ( ) ;
@@ -394,6 +394,37 @@ public bool AddMDIForm_CanExecuteBasedOnProjectType(ProjectType projectType)
394
394
}
395
395
}
396
396
397
+ [ Category ( "Code Explorer" ) ]
398
+ [ Test ]
399
+ public void AddMDIForm_CannotExecuteIfProjectAlreadyHasMDIForm ( )
400
+ {
401
+ var builder = new MockVbeBuilder ( ) ;
402
+ var project = builder . ProjectBuilder ( "TestProject1" , ProjectProtection . Unprotected , ProjectType . StandardExe )
403
+ . AddComponent ( "MDIForm1" , ComponentType . MDIForm , "" ) ;
404
+
405
+
406
+ var vbe = builder . AddProject ( project . Build ( ) ) . Build ( ) ;
407
+ var vbeEvents = MockVbeEvents . CreateMockVbeEvents ( vbe ) ;
408
+
409
+ var commands = new List < CommandBase > { new AddMDIFormCommand ( vbe . Object , new AddComponentCommand ( vbe . Object ) ) } ;
410
+
411
+ var projectRepository = new ProjectsRepository ( vbe . Object ) ;
412
+ var uiDispatcher = new Mock < IUiDispatcher > ( ) ;
413
+
414
+ using ( var state = new RubberduckParserState ( vbe . Object , projectRepository , new DeclarationFinderFactory ( ) , vbeEvents . Object ) )
415
+ {
416
+ var vm = new CodeExplorerViewModel ( new FolderHelper ( state ) , state , commands , _generalSettingsProvider . Object , _windowSettingsProvider . Object , uiDispatcher . Object , vbe . Object ) ;
417
+
418
+ var parser = MockParser . Create ( vbe . Object , state , projectRepository ) ;
419
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
420
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
421
+
422
+ vm . SelectedItem = vm . Projects . First ( ) . Items . First ( ) . Items . First ( ) ;
423
+
424
+ Assert . IsFalse ( vm . AddMDIFormCommand . CanExecute ( vm . SelectedItem ) ) ;
425
+ }
426
+ }
427
+
397
428
[ Category ( "Code Explorer" ) ]
398
429
[ Test ]
399
430
public void AddUserControlForm ( )
0 commit comments