@@ -16,6 +16,62 @@ namespace RubberduckTests.Inspections
16
16
[ TestClass ]
17
17
public class ParameterCanBeByValInspectionTests
18
18
{
19
+ [ TestMethod ]
20
+ [ TestCategory ( "Inspections" ) ]
21
+ public void ParameterCanBeByVal_NoResultForByValClassInProperty ( )
22
+ {
23
+ const string class1Code = @"
24
+ Option Explicit
25
+ Public Sub DoSomething()
26
+ End sub
27
+ " ;
28
+
29
+ const string inputCode =
30
+ @"Public Property Set Foo(ByVal value As Class1)
31
+ End Property" ;
32
+
33
+ //Arrange
34
+ var builder = new MockVbeBuilder ( ) ;
35
+ var vbe = builder . ProjectBuilder ( "TestProject1" , ProjectProtection . Unprotected )
36
+ . AddComponent ( "Class1" , ComponentType . ClassModule , class1Code )
37
+ . AddComponent ( "Module1" , ComponentType . StandardModule , inputCode )
38
+ . MockVbeBuilder ( ) . Build ( ) ;
39
+
40
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object ) ) ;
41
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
42
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
43
+
44
+ var inspection = new ParameterCanBeByValInspection ( parser . State ) ;
45
+ var inspectionResults = inspection . GetInspectionResults ( ) ;
46
+
47
+ Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
48
+ }
49
+
50
+ [ TestMethod ]
51
+ [ TestCategory ( "Inspections" ) ]
52
+ public void ParameterCanBeByVal_NoResultForByValObjectInProperty ( )
53
+ {
54
+ const string inputCode =
55
+ @"Public Property Set Foo(ByVal value As Object)
56
+ End Property" ;
57
+
58
+ //Arrange
59
+ var builder = new MockVbeBuilder ( ) ;
60
+ IVBComponent component ;
61
+ var vbe = builder . BuildFromSingleModule ( inputCode , ComponentType . ClassModule , out component ) ;
62
+ var mockHost = new Mock < IHostApplication > ( ) ;
63
+ mockHost . SetupAllProperties ( ) ;
64
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object ) ) ;
65
+
66
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
67
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
68
+
69
+ var inspection = new ParameterCanBeByValInspection ( parser . State ) ;
70
+ var inspectionResults = inspection . GetInspectionResults ( ) ;
71
+
72
+ Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
73
+ }
74
+
19
75
[ TestMethod ]
20
76
[ TestCategory ( "Inspections" ) ]
21
77
public void ParameterCanBeByVal_NoResultForByValObject ( )
0 commit comments