@@ -42,6 +42,19 @@ End Sub
4242
4343 var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
4444
45+ GetExcelRangeDeclarations ( ) . ForEach ( d => parser . State . AddDeclaration ( d ) ) ;
46+
47+ parser . Parse ( new CancellationTokenSource ( ) ) ;
48+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
49+
50+ var inspection = new ImplicitActiveSheetReferenceInspection ( vbe . Object , parser . State ) ;
51+ var inspectionResults = inspection . GetInspectionResults ( ) ;
52+
53+ Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
54+ }
55+
56+ private List < Declaration > GetExcelRangeDeclarations ( )
57+ {
4558 var excelDeclaration = new ProjectDeclaration ( new QualifiedMemberName ( new QualifiedModuleName ( "Excel" ,
4659 "C:\\ Program Files\\ Microsoft Office\\ Root\\ Office 16\\ EXCEL.EXE" , "Excel" ) , "Excel" ) , "Excel" , true ) ;
4760
@@ -87,21 +100,16 @@ End Sub
87100 rangeDeclaration . AddParameter ( firstParamDeclaration ) ;
88101 rangeDeclaration . AddParameter ( secondParamDeclaration ) ;
89102
90- parser . State . AddDeclaration ( excelDeclaration ) ;
91- parser . State . AddDeclaration ( globalDeclaration ) ;
92- parser . State . AddDeclaration ( globalCoClassDeclaration ) ;
93- parser . State . AddDeclaration ( rangeClassModuleDeclaration ) ;
94- parser . State . AddDeclaration ( rangeDeclaration ) ;
95- parser . State . AddDeclaration ( firstParamDeclaration ) ;
96- parser . State . AddDeclaration ( secondParamDeclaration ) ;
97-
98- parser . Parse ( new CancellationTokenSource ( ) ) ;
99- if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
100-
101- var inspection = new ImplicitActiveSheetReferenceInspection ( vbe . Object , parser . State ) ;
102- var inspectionResults = inspection . GetInspectionResults ( ) ;
103-
104- Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
103+ return new List < Declaration >
104+ {
105+ excelDeclaration ,
106+ globalDeclaration ,
107+ globalCoClassDeclaration ,
108+ rangeClassModuleDeclaration ,
109+ rangeDeclaration ,
110+ firstParamDeclaration ,
111+ secondParamDeclaration ,
112+ } ;
105113 }
106114 }
107115}
0 commit comments