2
2
using System . Threading ;
3
3
using Microsoft . VisualStudio . TestTools . UnitTesting ;
4
4
using Rubberduck . Inspections . Concrete ;
5
- using Rubberduck . Inspections . QuickFixes ;
6
5
using Rubberduck . Parsing . VBA ;
7
6
using Rubberduck . VBEditor . SafeComWrappers ;
8
7
using RubberduckTests . Mocks ;
@@ -227,176 +226,5 @@ End Sub
227
226
228
227
Assert . IsFalse ( inspectionResults . Any ( ) ) ;
229
228
}
230
-
231
- [ TestMethod ]
232
- [ DeploymentItem ( @"Testfiles\" ) ]
233
- [ TestCategory ( "Inspections" ) ]
234
- public void ApplicationWorksheetFunction_IgnoreQuickFixWorks ( )
235
- {
236
- const string inputCode =
237
- @"Sub ExcelSub()
238
- Dim foo As Double
239
- foo = Application.Pi
240
- End Sub
241
- " ;
242
-
243
- const string expectedCode =
244
- @"Sub ExcelSub()
245
- Dim foo As Double
246
- '@Ignore ApplicationWorksheetFunction
247
- foo = Application.Pi
248
- End Sub
249
- " ;
250
-
251
- var builder = new MockVbeBuilder ( ) ;
252
- var project = builder . ProjectBuilder ( "VBAProject" , ProjectProtection . Unprotected )
253
- . AddComponent ( "Module1" , ComponentType . StandardModule , inputCode )
254
- . AddReference ( "Excel" , MockVbeBuilder . LibraryPathMsExcel , 1 , 8 , true )
255
- . Build ( ) ;
256
-
257
- var vbe = builder . AddProject ( project ) . Build ( ) ;
258
- var component = vbe . Object . SelectedVBComponent ;
259
-
260
- var parser = MockParser . Create ( vbe . Object ) ;
261
-
262
- parser . State . AddTestLibrary ( "Excel.1.8.xml" ) ;
263
-
264
- parser . Parse ( new CancellationTokenSource ( ) ) ;
265
- if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
266
-
267
- var inspection = new ApplicationWorksheetFunctionInspection ( parser . State ) ;
268
- var inspectionResults = inspection . GetInspectionResults ( ) ;
269
-
270
- new IgnoreOnceQuickFix ( parser . State , new [ ] { inspection } ) . Fix ( inspectionResults . First ( ) ) ;
271
-
272
- Assert . AreEqual ( expectedCode , parser . State . GetRewriter ( component ) . GetText ( ) ) ;
273
- }
274
-
275
- [ TestMethod ]
276
- [ DeploymentItem ( @"Testfiles\" ) ]
277
- [ TestCategory ( "Inspections" ) ]
278
- public void ApplicationWorksheetFunction_UseExplicitlyQuickFixWorks ( )
279
- {
280
- const string inputCode =
281
- @"Sub ExcelSub()
282
- Dim foo As Double
283
- foo = Application.Pi
284
- End Sub
285
- " ;
286
-
287
- const string expectedCode =
288
- @"Sub ExcelSub()
289
- Dim foo As Double
290
- foo = Application.WorksheetFunction.Pi
291
- End Sub
292
- " ;
293
-
294
- var builder = new MockVbeBuilder ( ) ;
295
- var project = builder . ProjectBuilder ( "VBAProject" , ProjectProtection . Unprotected )
296
- . AddComponent ( "Module1" , ComponentType . StandardModule , inputCode )
297
- . AddReference ( "Excel" , MockVbeBuilder . LibraryPathMsExcel , 1 , 8 , true )
298
- . Build ( ) ;
299
-
300
- var vbe = builder . AddProject ( project ) . Build ( ) ;
301
-
302
- var parser = MockParser . Create ( vbe . Object ) ;
303
-
304
- parser . State . AddTestLibrary ( "Excel.1.8.xml" ) ;
305
-
306
- parser . Parse ( new CancellationTokenSource ( ) ) ;
307
- if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
308
-
309
- var inspection = new ApplicationWorksheetFunctionInspection ( parser . State ) ;
310
- var inspectionResults = inspection . GetInspectionResults ( ) ;
311
-
312
- new ApplicationWorksheetFunctionQuickFix ( parser . State ) . Fix ( inspectionResults . First ( ) ) ;
313
- Assert . AreEqual ( expectedCode , parser . State . GetRewriter ( project . Object . VBComponents . First ( ) ) . GetText ( ) ) ;
314
- }
315
-
316
- [ TestMethod ]
317
- [ DeploymentItem ( @"Testfiles\" ) ]
318
- [ TestCategory ( "Inspections" ) ]
319
- public void ApplicationWorksheetFunction_UseExplicitlyQuickFixWorks_WithBlock ( )
320
- {
321
- const string inputCode =
322
- @"Sub ExcelSub()
323
- Dim foo As Double
324
- With Application
325
- foo = .Pi
326
- End With
327
- End Sub
328
- " ;
329
-
330
- const string expectedCode =
331
- @"Sub ExcelSub()
332
- Dim foo As Double
333
- With Application
334
- foo = .WorksheetFunction.Pi
335
- End With
336
- End Sub
337
- " ;
338
-
339
- var builder = new MockVbeBuilder ( ) ;
340
- var project = builder . ProjectBuilder ( "VBAProject" , ProjectProtection . Unprotected )
341
- . AddComponent ( "Module1" , ComponentType . StandardModule , inputCode )
342
- . AddReference ( "Excel" , MockVbeBuilder . LibraryPathMsExcel , 1 , 8 , true )
343
- . Build ( ) ;
344
-
345
- var vbe = builder . AddProject ( project ) . Build ( ) ;
346
-
347
- var parser = MockParser . Create ( vbe . Object ) ;
348
-
349
- parser . State . AddTestLibrary ( "Excel.1.8.xml" ) ;
350
-
351
- parser . Parse ( new CancellationTokenSource ( ) ) ;
352
- if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
353
-
354
- var inspection = new ApplicationWorksheetFunctionInspection ( parser . State ) ;
355
- var inspectionResults = inspection . GetInspectionResults ( ) ;
356
-
357
- new ApplicationWorksheetFunctionQuickFix ( parser . State ) . Fix ( inspectionResults . First ( ) ) ;
358
- Assert . AreEqual ( expectedCode , parser . State . GetRewriter ( project . Object . VBComponents . First ( ) ) . GetText ( ) ) ;
359
- }
360
-
361
- [ TestMethod ]
362
- [ DeploymentItem ( @"Testfiles\" ) ]
363
- [ TestCategory ( "Inspections" ) ]
364
- public void ApplicationWorksheetFunction_UseExplicitlyQuickFixWorks_HasParameters ( )
365
- {
366
- const string inputCode =
367
- @"Sub ExcelSub()
368
- Dim foo As String
369
- foo = Application.Proper(""foobar"")
370
- End Sub
371
- " ;
372
-
373
- const string expectedCode =
374
- @"Sub ExcelSub()
375
- Dim foo As String
376
- foo = Application.WorksheetFunction.Proper(""foobar"")
377
- End Sub
378
- " ;
379
-
380
- var builder = new MockVbeBuilder ( ) ;
381
- var project = builder . ProjectBuilder ( "VBAProject" , ProjectProtection . Unprotected )
382
- . AddComponent ( "Module1" , ComponentType . StandardModule , inputCode )
383
- . AddReference ( "Excel" , MockVbeBuilder . LibraryPathMsExcel , 1 , 8 , true )
384
- . Build ( ) ;
385
-
386
- var vbe = builder . AddProject ( project ) . Build ( ) ;
387
-
388
- var parser = MockParser . Create ( vbe . Object ) ;
389
-
390
- parser . State . AddTestLibrary ( "Excel.1.8.xml" ) ;
391
-
392
- parser . Parse ( new CancellationTokenSource ( ) ) ;
393
- if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
394
-
395
- var inspection = new ApplicationWorksheetFunctionInspection ( parser . State ) ;
396
- var inspectionResults = inspection . GetInspectionResults ( ) ;
397
-
398
- new ApplicationWorksheetFunctionQuickFix ( parser . State ) . Fix ( inspectionResults . First ( ) ) ;
399
- Assert . AreEqual ( expectedCode , parser . State . GetRewriter ( project . Object . VBComponents . First ( ) ) . GetText ( ) ) ;
400
- }
401
229
}
402
230
}
0 commit comments