@@ -652,6 +652,58 @@ End Sub
652
652
Assert . AreEqual ( expectedInterfaceCode , actualInterfaceCode ) ;
653
653
}
654
654
655
+ [ Test ]
656
+ [ Category ( "Refactorings" ) ]
657
+ [ Category ( "Extract Interface" ) ]
658
+ public void ExtractInterfaceRefactoring_PutsInterfaceInFolderOfClassItIsExtractedFrom ( )
659
+ {
660
+ //Input
661
+ const string inputCode =
662
+ @"'@Folder(""MyFolder.MySubFolder"")
663
+
664
+ Public Sub Foo(ByVal arg1 As Integer, ByVal arg2 As String)
665
+ End Sub" ;
666
+ var selection = new Selection ( 1 , 23 , 1 , 27 ) ;
667
+
668
+ //Expectation
669
+ const string expectedCode =
670
+ @"Implements IClass
671
+
672
+ '@Folder(""MyFolder.MySubFolder"")
673
+
674
+ Public Sub Foo(ByVal arg1 As Integer, ByVal arg2 As String)
675
+ End Sub
676
+
677
+ Private Sub IClass_Foo(ByVal arg1 As Integer, ByVal arg2 As String)
678
+ Err.Raise 5 'TODO implement interface member
679
+ End Sub
680
+ " ;
681
+
682
+ const string expectedInterfaceCode =
683
+ @"Option Explicit
684
+
685
+ '@Folder(""MyFolder.MySubFolder"")
686
+ '@Interface
687
+
688
+ Public Sub Foo(ByVal arg1 As Integer, ByVal arg2 As String)
689
+ End Sub
690
+ " ;
691
+ Func < ExtractInterfaceModel , ExtractInterfaceModel > presenterAction = model =>
692
+ {
693
+ foreach ( var interfaceMember in model . Members )
694
+ {
695
+ interfaceMember . IsSelected = true ;
696
+ }
697
+
698
+ return model ;
699
+ } ;
700
+
701
+ var actualCode = RefactoredCode ( "Class" , selection , presenterAction , null , false , ( "Class" , inputCode , ComponentType . ClassModule ) ) ;
702
+ Assert . AreEqual ( expectedCode , actualCode [ "Class" ] ) ;
703
+ var actualInterfaceCode = actualCode [ actualCode . Keys . Single ( componentName => ! componentName . Equals ( "Class" ) ) ] ;
704
+ Assert . AreEqual ( expectedInterfaceCode , actualInterfaceCode ) ;
705
+ }
706
+
655
707
protected override IRefactoring TestRefactoring ( IRewritingManager rewritingManager , RubberduckParserState state , IRefactoringPresenterFactory factory , ISelectionService selectionService )
656
708
{
657
709
var uiDispatcherMock = new Mock < IUiDispatcher > ( ) ;
0 commit comments