@@ -42,6 +42,19 @@ End Sub
42
42
43
43
var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
44
44
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
+ {
45
58
var excelDeclaration = new ProjectDeclaration ( new QualifiedMemberName ( new QualifiedModuleName ( "Excel" ,
46
59
"C:\\ Program Files\\ Microsoft Office\\ Root\\ Office 16\\ EXCEL.EXE" , "Excel" ) , "Excel" ) , "Excel" , true ) ;
47
60
@@ -87,21 +100,16 @@ End Sub
87
100
rangeDeclaration . AddParameter ( firstParamDeclaration ) ;
88
101
rangeDeclaration . AddParameter ( secondParamDeclaration ) ;
89
102
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
+ } ;
105
113
}
106
114
}
107
115
}
0 commit comments