@@ -334,7 +334,7 @@ Sub Foo(arg1 As String)
334334 }
335335
336336 [ TestMethod ]
337- public void ParameterCanBeByVal_InterfaceMember ( )
337+ public void ParameterCanBeByVal_InterfaceMember_SingleParam ( )
338338 {
339339 //Input
340340 const string inputCode1 =
@@ -351,6 +351,43 @@ Private Sub IClass1_DoSomething(ByRef a As Integer)
351351 var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
352352 . AddComponent ( "IClass1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
353353 . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
354+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
355+ . Build ( ) ;
356+ var vbe = builder . AddProject ( project ) . Build ( ) ;
357+
358+ var mockHost = new Mock < IHostApplication > ( ) ;
359+ mockHost . SetupAllProperties ( ) ;
360+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
361+
362+ parser . Parse ( new CancellationTokenSource ( ) ) ;
363+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
364+
365+ var inspection = new ParameterCanBeByValInspection ( parser . State ) ;
366+ var inspectionResults = inspection . GetInspectionResults ( ) ;
367+
368+ Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
369+ }
370+
371+ [ TestMethod ]
372+ public void ParameterCanBeByVal_InterfaceMember_SingleParamUsedByRef ( )
373+ {
374+ //Input
375+ const string inputCode1 =
376+ @"Public Sub DoSomething(ByRef a As Integer)
377+ End Sub" ;
378+ const string inputCode2 =
379+ @"Implements IClass1
380+
381+ Private Sub IClass1_DoSomething(ByRef a As Integer)
382+ a = 42
383+ End Sub" ;
384+
385+ //Arrange
386+ var builder = new MockVbeBuilder ( ) ;
387+ var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
388+ . AddComponent ( "IClass1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
389+ . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
390+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
354391 . Build ( ) ;
355392 var vbe = builder . AddProject ( project ) . Build ( ) ;
356393
@@ -366,7 +403,48 @@ Private Sub IClass1_DoSomething(ByRef a As Integer)
366403
367404 Assert . IsFalse ( inspectionResults . Any ( ) ) ;
368405 }
369-
406+
407+ [ TestMethod ]
408+ public void ParameterCanBeByVal_InterfaceMember_MultipleParams_OneCanBeByVal ( )
409+ {
410+ //Input
411+ const string inputCode1 =
412+ @"Public Sub DoSomething(ByRef a As Integer, ByRef b As Integer)
413+ End Sub" ;
414+ const string inputCode2 =
415+ @"Implements IClass1
416+
417+ Private Sub IClass1_DoSomething(ByRef a As Integer, ByRef b As Integer)
418+ b = 42
419+ End Sub" ;
420+ const string inputCode3 =
421+ @"Implements IClass1
422+
423+ Private Sub IClass1_DoSomething(ByRef a As Integer, ByRef b As Integer)
424+ End Sub" ;
425+
426+ //Arrange
427+ var builder = new MockVbeBuilder ( ) ;
428+ var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
429+ . AddComponent ( "IClass1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
430+ . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
431+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode3 )
432+ . Build ( ) ;
433+ var vbe = builder . AddProject ( project ) . Build ( ) ;
434+
435+ var mockHost = new Mock < IHostApplication > ( ) ;
436+ mockHost . SetupAllProperties ( ) ;
437+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
438+
439+ parser . Parse ( new CancellationTokenSource ( ) ) ;
440+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
441+
442+ var inspection = new ParameterCanBeByValInspection ( parser . State ) ;
443+ var inspectionResults = inspection . GetInspectionResults ( ) ;
444+
445+ Assert . AreEqual ( "a" , inspectionResults . Single ( ) . Target . IdentifierName ) ;
446+ }
447+
370448 [ TestMethod ]
371449 public void ParameterCanBeByVal_Event ( )
372450 {
0 commit comments