@@ -9,11 +9,12 @@ namespace RubberduckTests.Refactoring.EncapsulateField
9
9
[ TestFixture ]
10
10
public class EncapsulateFieldCodeBuilderTests
11
11
{
12
- [ Test ]
12
+ [ TestCase ( "Public" ) ]
13
+ [ TestCase ( "Private" ) ]
13
14
[ Category ( "Refactorings" ) ]
14
15
[ Category ( "Encapsulate Field" ) ]
15
16
[ Category ( nameof ( EncapsulateFieldCodeBuilder ) ) ]
16
- public void BuildPropertyBlock_VariantGet ( )
17
+ public void BuildPropertyBlock_VariantGet ( string accessibility )
17
18
{
18
19
var attrSet = new PropertyAttributeSet ( )
19
20
{
@@ -22,11 +23,11 @@ public void BuildPropertyBlock_VariantGet()
22
23
AsTypeName = "Variant" ,
23
24
} ;
24
25
25
- var results = GeneratePropertyBlocks ( "Public xxx As Variant", "xxx" , attrSet ) ;
26
+ var results = GeneratePropertyBlocks ( $ " { accessibility } xxx As Variant", "xxx" , attrSet ) ;
26
27
var actualLines = results . Get . Split ( new string [ ] { Environment . NewLine } , StringSplitOptions . None ) . ToList ( ) ;
27
28
28
29
Assert . AreEqual ( 7 , actualLines . Count ) ;
29
- Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "Public Property Get { attrSet . PropertyName } () As { attrSet . AsTypeName } ") ;
30
+ Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "{ accessibility } Property Get { attrSet . PropertyName } () As { attrSet . AsTypeName } ") ;
30
31
Assert . AreEqual ( actualLines [ 1 ] . Trim ( ) , $ "If IsObject({ attrSet . BackingField } ) Then") ;
31
32
Assert . AreEqual ( actualLines [ 2 ] . Trim ( ) , $ "Set { attrSet . PropertyName } = { attrSet . BackingField } ") ;
32
33
Assert . AreEqual ( actualLines [ 3 ] . Trim ( ) , "Else" ) ;
@@ -35,13 +36,16 @@ public void BuildPropertyBlock_VariantGet()
35
36
Assert . AreEqual ( actualLines [ 6 ] . Trim ( ) , "End Property" ) ;
36
37
}
37
38
38
- [ TestCase ( "Variant" ) ]
39
- [ TestCase ( "Long" ) ]
40
- [ TestCase ( "String" ) ]
39
+ [ TestCase ( "Variant" , "Public" ) ]
40
+ [ TestCase ( "Long" , "Public" ) ]
41
+ [ TestCase ( "String" , "Public" ) ]
42
+ [ TestCase ( "Variant" , "Private" ) ]
43
+ [ TestCase ( "Long" , "Private" ) ]
44
+ [ TestCase ( "String" , "Private" ) ]
41
45
[ Category ( "Refactorings" ) ]
42
46
[ Category ( "Encapsulate Field" ) ]
43
47
[ Category ( nameof ( EncapsulateFieldCodeBuilder ) ) ]
44
- public void BuildPropertyBlock_Let ( string asTypeName )
48
+ public void BuildPropertyBlock_Let ( string asTypeName , string accessibility )
45
49
{
46
50
var attrSet = new PropertyAttributeSet ( )
47
51
{
@@ -52,22 +56,25 @@ public void BuildPropertyBlock_Let(string asTypeName)
52
56
AsTypeName = asTypeName ,
53
57
} ;
54
58
55
- var results = GeneratePropertyBlocks ( $ "Public xxx As { asTypeName } ", "xxx" , attrSet ) ;
59
+ var results = GeneratePropertyBlocks ( $ "{ accessibility } xxx As { asTypeName } ", "xxx" , attrSet ) ;
56
60
var actualLines = results . Let . Split ( new string [ ] { Environment . NewLine } , StringSplitOptions . None ) . ToList ( ) ;
57
61
58
62
Assert . AreEqual ( 3 , actualLines . Count ) ;
59
- Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "Public Property Let { attrSet . PropertyName } (ByVal { attrSet . RHSParameterIdentifier } As { asTypeName } )") ;
63
+ Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "{ accessibility } Property Let { attrSet . PropertyName } (ByVal { attrSet . RHSParameterIdentifier } As { asTypeName } )") ;
60
64
Assert . AreEqual ( actualLines [ 1 ] . Trim ( ) , $ "{ attrSet . BackingField } = { attrSet . RHSParameterIdentifier } ") ;
61
65
Assert . AreEqual ( actualLines [ 2 ] . Trim ( ) , "End Property" ) ;
62
66
}
63
67
64
- [ TestCase ( "Variant" ) ]
65
- [ TestCase ( "Long" ) ]
66
- [ TestCase ( "String" ) ]
68
+ [ TestCase ( "Variant" , "Public" ) ]
69
+ [ TestCase ( "Long" , "Public" ) ]
70
+ [ TestCase ( "String" , "Public" ) ]
71
+ [ TestCase ( "Variant" , "Private" ) ]
72
+ [ TestCase ( "Long" , "Private" ) ]
73
+ [ TestCase ( "String" , "Private" ) ]
67
74
[ Category ( "Refactorings" ) ]
68
75
[ Category ( "Encapsulate Field" ) ]
69
76
[ Category ( nameof ( EncapsulateFieldCodeBuilder ) ) ]
70
- public void BuildPropertyBlock_Set ( string asTypeName )
77
+ public void BuildPropertyBlock_Set ( string asTypeName , string accessibility )
71
78
{
72
79
var attrSet = new PropertyAttributeSet ( )
73
80
{
@@ -78,11 +85,11 @@ public void BuildPropertyBlock_Set(string asTypeName)
78
85
AsTypeName = asTypeName ,
79
86
} ;
80
87
81
- var results = GeneratePropertyBlocks ( $ "Public xxx As { asTypeName } ", "xxx" , attrSet ) ;
88
+ var results = GeneratePropertyBlocks ( $ "{ accessibility } xxx As { asTypeName } ", "xxx" , attrSet ) ;
82
89
var actualLines = results . Set . Split ( new string [ ] { Environment . NewLine } , StringSplitOptions . None ) . ToList ( ) ;
83
90
84
91
Assert . AreEqual ( 3 , actualLines . Count ) ;
85
- Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "Public Property Set { attrSet . PropertyName } (ByVal { attrSet . RHSParameterIdentifier } As { asTypeName } )") ;
92
+ Assert . AreEqual ( actualLines [ 0 ] . Trim ( ) , $ "{ accessibility } Property Set { attrSet . PropertyName } (ByVal { attrSet . RHSParameterIdentifier } As { asTypeName } )") ;
86
93
Assert . AreEqual ( actualLines [ 1 ] . Trim ( ) , $ "Set { attrSet . BackingField } = { attrSet . RHSParameterIdentifier } ") ;
87
94
Assert . AreEqual ( actualLines [ 2 ] . Trim ( ) , "End Property" ) ;
88
95
}
0 commit comments