77using Rubberduck . VBEditor . Extensions ;
88using Rubberduck . VBEditor . VBEHost ;
99using RubberduckTests . Mocks ;
10+ using Rubberduck . Settings ;
11+ using Rubberduck . Inspections . Rubberduck . Inspections ;
12+ using System . Threading ;
1013
1114namespace RubberduckTests . Inspections
1215{
@@ -22,6 +25,10 @@ Call Foo
2225End Sub" ;
2326
2427 //Arrange
28+ var settings = new Mock < IGeneralConfigService > ( ) ;
29+ var config = GetTestConfig ( ) ;
30+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
31+
2532 var builder = new MockVbeBuilder ( ) ;
2633 VBComponent component ;
2734 var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
@@ -33,7 +40,9 @@ Call Foo
3340 if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
3441
3542 var inspection = new ObsoleteCallStatementInspection ( parser . State ) ;
36- var inspectionResults = inspection . GetInspectionResults ( ) ;
43+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
44+
45+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
3746
3847 Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
3948 }
@@ -47,6 +56,10 @@ public void ObsoleteCallStatement_DoesNotReturnResult()
4756End Sub" ;
4857
4958 //Arrange
59+ var settings = new Mock < IGeneralConfigService > ( ) ;
60+ var config = GetTestConfig ( ) ;
61+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
62+
5063 var builder = new MockVbeBuilder ( ) ;
5164 VBComponent component ;
5265 var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
@@ -58,7 +71,9 @@ public void ObsoleteCallStatement_DoesNotReturnResult()
5871 if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
5972
6073 var inspection = new ObsoleteCallStatementInspection ( parser . State ) ;
61- var inspectionResults = inspection . GetInspectionResults ( ) ;
74+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
75+
76+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
6277
6378 Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
6479 }
@@ -76,6 +91,10 @@ Call Foo
7691End Sub" ;
7792
7893 //Arrange
94+ var settings = new Mock < IGeneralConfigService > ( ) ;
95+ var config = GetTestConfig ( ) ;
96+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
97+
7998 var builder = new MockVbeBuilder ( ) ;
8099 VBComponent component ;
81100 var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
@@ -87,7 +106,9 @@ Call Foo
87106 if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
88107
89108 var inspection = new ObsoleteCallStatementInspection ( parser . State ) ;
90- var inspectionResults = inspection . GetInspectionResults ( ) ;
109+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
110+
111+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
91112
92113 Assert . AreEqual ( 2 , inspectionResults . Count ( ) ) ;
93114 }
@@ -105,6 +126,10 @@ Sub Goo(arg1 As Integer, arg1 As String)
105126End Sub" ;
106127
107128 //Arrange
129+ var settings = new Mock < IGeneralConfigService > ( ) ;
130+ var config = GetTestConfig ( ) ;
131+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
132+
108133 var builder = new MockVbeBuilder ( ) ;
109134 VBComponent component ;
110135 var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
@@ -116,7 +141,9 @@ Sub Goo(arg1 As Integer, arg1 As String)
116141 if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
117142
118143 var inspection = new ObsoleteCallStatementInspection ( parser . State ) ;
119- var inspectionResults = inspection . GetInspectionResults ( ) ;
144+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
145+
146+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
120147
121148 Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
122149 }
@@ -143,6 +170,10 @@ Sub Goo(arg1 As Integer, arg1 As String)
143170End Sub" ;
144171
145172 //Arrange
173+ var settings = new Mock < IGeneralConfigService > ( ) ;
174+ var config = GetTestConfig ( ) ;
175+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
176+
146177 var builder = new MockVbeBuilder ( ) ;
147178 VBComponent component ;
148179 var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
@@ -156,7 +187,9 @@ Sub Goo(arg1 As Integer, arg1 As String)
156187 if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
157188
158189 var inspection = new ObsoleteCallStatementInspection ( parser . State ) ;
159- var inspectionResults = inspection . GetInspectionResults ( ) ;
190+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
191+
192+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
160193
161194 foreach ( var inspectionResult in inspectionResults )
162195 {
@@ -182,5 +215,21 @@ public void InspectionName()
182215
183216 Assert . AreEqual ( inspectionName , inspection . Name ) ;
184217 }
218+
219+ private Configuration GetTestConfig ( )
220+ {
221+ return new Configuration
222+ {
223+ UserSettings = new UserSettings
224+ {
225+ CodeInspectionSettings = new CodeInspectionSettings
226+ {
227+ CodeInspections = new [ ] {
228+ new CodeInspectionSetting { Description = new ObsoleteCallStatementInspection ( null ) . Description , Severity = CodeInspectionSeverity . Suggestion , }
229+ }
230+ }
231+ }
232+ } ;
233+ }
185234 }
186235}
0 commit comments