@@ -16,19 +16,20 @@ public partial class CoverageTests
16
16
[ Theory ]
17
17
[ InlineData ( true ) ]
18
18
[ InlineData ( false ) ]
19
- public void SkipAutoProps ( bool skipAutoProps )
19
+ public void SkipClassWithAutoProps ( bool skipAutoProps )
20
20
{
21
21
string path = Path . GetTempFileName ( ) ;
22
22
try
23
23
{
24
24
FunctionExecutor . Run ( async ( string [ ] parameters ) =>
25
25
{
26
- CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < AutoProps > ( instance =>
26
+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < ClassWithAutoProps > ( instance =>
27
27
{
28
28
instance . AutoPropsNonInit = 10 ;
29
29
instance . AutoPropsInit = 20 ;
30
30
int readValue = instance . AutoPropsNonInit ;
31
31
readValue = instance . AutoPropsInit ;
32
+ readValue = instance . AutoPropsInitKeyword ;
32
33
return Task . CompletedTask ;
33
34
} ,
34
35
persistPrepareResultToFile : parameters [ 0 ] , skipAutoProps : bool . Parse ( parameters [ 1 ] ) ) ;
@@ -40,8 +41,8 @@ public void SkipAutoProps(bool skipAutoProps)
40
41
{
41
42
TestInstrumentationHelper . GetCoverageResult ( path )
42
43
. Document ( "Instrumentation.AutoProps.cs" )
43
- . AssertNonInstrumentedLines ( BuildConfiguration . Debug , 12 , 13 )
44
- . AssertNonInstrumentedLines ( BuildConfiguration . Release , 12 , 13 )
44
+ . AssertNonInstrumentedLines ( BuildConfiguration . Debug , 12 , 14 )
45
+ . AssertNonInstrumentedLines ( BuildConfiguration . Release , 12 , 14 )
45
46
. AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 9 , 11 )
46
47
. AssertLinesCovered ( BuildConfiguration . Debug , ( 7 , 1 ) )
47
48
. AssertLinesCovered ( BuildConfiguration . Release , ( 10 , 1 ) ) ;
@@ -50,9 +51,184 @@ public void SkipAutoProps(bool skipAutoProps)
50
51
{
51
52
TestInstrumentationHelper . GetCoverageResult ( path )
52
53
. Document ( "Instrumentation.AutoProps.cs" )
53
- . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 7 , 13 )
54
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 7 , 14 )
54
55
. AssertLinesCoveredFromTo ( BuildConfiguration . Release , 10 , 10 )
55
- . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 12 , 13 ) ;
56
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 12 , 14 ) ;
57
+ }
58
+ }
59
+ finally
60
+ {
61
+ File . Delete ( path ) ;
62
+ }
63
+ }
64
+
65
+ [ Theory ]
66
+ [ InlineData ( true ) ]
67
+ [ InlineData ( false ) ]
68
+ public void SkipClassWithAutoPropsPrimaryConstructor ( bool skipAutoProps )
69
+ {
70
+ string path = Path . GetTempFileName ( ) ;
71
+ try
72
+ {
73
+ FunctionExecutor . Run ( async ( string [ ] parameters ) =>
74
+ {
75
+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < ClassWithAutoPropsPrimaryConstructor > ( instance =>
76
+ {
77
+ return Task . CompletedTask ;
78
+ } ,
79
+ persistPrepareResultToFile : parameters [ 0 ] , skipAutoProps : bool . Parse ( parameters [ 1 ] ) ) ;
80
+
81
+ return 0 ;
82
+ } , [ path , skipAutoProps . ToString ( ) ] ) ;
83
+
84
+ if ( skipAutoProps )
85
+ {
86
+ TestInstrumentationHelper . GetCoverageResult ( path )
87
+ . Document ( "Instrumentation.AutoProps.cs" )
88
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 28 , 28 )
89
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 28 , 28 )
90
+ . AssertNonInstrumentedLines ( BuildConfiguration . Debug , 30 , 31 , 32 )
91
+ . AssertNonInstrumentedLines ( BuildConfiguration . Release , 30 , 31 , 32 ) ;
92
+ }
93
+ else
94
+ {
95
+ TestInstrumentationHelper . GetCoverageResult ( path )
96
+ . Document ( "Instrumentation.AutoProps.cs" )
97
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 28 , 28 )
98
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 30 , 32 )
99
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 28 , 28 )
100
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 30 , 32 ) ;
101
+ }
102
+ }
103
+ finally
104
+ {
105
+ File . Delete ( path ) ;
106
+ }
107
+ }
108
+
109
+ [ Theory ]
110
+ [ InlineData ( true ) ]
111
+ [ InlineData ( false ) ]
112
+ public void SkipRecordWithAutoProps ( bool skipAutoProps )
113
+ {
114
+ string path = Path . GetTempFileName ( ) ;
115
+ try
116
+ {
117
+ FunctionExecutor . Run ( async ( string [ ] parameters ) =>
118
+ {
119
+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < RecordWithAutoProps > ( instance =>
120
+ {
121
+ instance . AutoPropsNonInit = 10 ;
122
+ instance . AutoPropsInit = 20 ;
123
+ int readValue = instance . AutoPropsNonInit ;
124
+ readValue = instance . AutoPropsInit ;
125
+ readValue = instance . AutoPropsInitKeyword ;
126
+ return Task . CompletedTask ;
127
+ } ,
128
+ persistPrepareResultToFile : parameters [ 0 ] , skipAutoProps : bool . Parse ( parameters [ 1 ] ) ) ;
129
+
130
+ return 0 ;
131
+ } , [ path , skipAutoProps . ToString ( ) ] ) ;
132
+
133
+ if ( skipAutoProps )
134
+ {
135
+ TestInstrumentationHelper . GetCoverageResult ( path )
136
+ . Document ( "Instrumentation.AutoProps.cs" )
137
+ . AssertNonInstrumentedLines ( BuildConfiguration . Debug , 43 , 45 )
138
+ . AssertNonInstrumentedLines ( BuildConfiguration . Release , 43 , 45 )
139
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 40 , 42 )
140
+ . AssertLinesCovered ( BuildConfiguration . Debug , ( 39 , 1 ) )
141
+ . AssertLinesCovered ( BuildConfiguration . Release , ( 39 , 1 ) ) ;
142
+ }
143
+ else
144
+ {
145
+ TestInstrumentationHelper . GetCoverageResult ( path )
146
+ . Document ( "Instrumentation.AutoProps.cs" )
147
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 38 , 45 ) // go on here
148
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 39 , 39 )
149
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 41 , 45 ) ;
150
+ }
151
+ }
152
+ finally
153
+ {
154
+ File . Delete ( path ) ;
155
+ }
156
+ }
157
+
158
+ [ Theory ]
159
+ [ InlineData ( true ) ]
160
+ [ InlineData ( false ) ]
161
+ public void SkipRecordWithAutoPropsPrimaryConstructor ( bool skipAutoProps )
162
+ {
163
+ string path = Path . GetTempFileName ( ) ;
164
+ try
165
+ {
166
+ FunctionExecutor . Run ( async ( string [ ] parameters ) =>
167
+ {
168
+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < RecordsWithPrimaryConstructor > ( instance =>
169
+ {
170
+ return Task . CompletedTask ;
171
+ } ,
172
+ persistPrepareResultToFile : parameters [ 0 ] , skipAutoProps : bool . Parse ( parameters [ 1 ] ) ) ;
173
+
174
+ return 0 ;
175
+ } , [ path , skipAutoProps . ToString ( ) ] ) ;
176
+
177
+ if ( skipAutoProps )
178
+ {
179
+ TestInstrumentationHelper . GetCoverageResult ( path )
180
+ . Document ( "Instrumentation.AutoProps.cs" )
181
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 50 , 50 )
182
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 36 , 36 ) ;
183
+ }
184
+ else
185
+ {
186
+ TestInstrumentationHelper . GetCoverageResult ( path )
187
+ . Document ( "Instrumentation.AutoProps.cs" )
188
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 50 , 50 )
189
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Release , 36 , 36 ) ;
190
+ }
191
+ }
192
+ finally
193
+ {
194
+ File . Delete ( path ) ;
195
+ }
196
+ }
197
+
198
+ [ Theory ]
199
+ [ InlineData ( true ) ]
200
+ [ InlineData ( false ) ]
201
+ public void SkipRecordWithAutoPropsPrimaryConstructorMultiline ( bool skipAutoProps )
202
+ {
203
+ string path = Path . GetTempFileName ( ) ;
204
+ try
205
+ {
206
+ FunctionExecutor . Run ( async ( string [ ] parameters ) =>
207
+ {
208
+ CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper . Run < RecordsWithPrimaryConstructor > ( instance =>
209
+ {
210
+ return Task . CompletedTask ;
211
+ } ,
212
+ persistPrepareResultToFile : parameters [ 0 ] , skipAutoProps : bool . Parse ( parameters [ 1 ] ) ) ;
213
+
214
+ return 0 ;
215
+ } , [ path , skipAutoProps . ToString ( ) ] ) ;
216
+
217
+ if ( skipAutoProps )
218
+ {
219
+ TestInstrumentationHelper . GetCoverageResult ( path )
220
+ . Document ( "Instrumentation.AutoProps.cs" )
221
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 52 , 55 )
222
+ . AssertLinesCoveredFromTo ( BuildConfiguration . Debug , 52 , 55 ) ;
223
+ }
224
+ else
225
+ {
226
+ TestInstrumentationHelper . GetCoverageResult ( path )
227
+ . Document ( "Instrumentation.AutoProps.cs" )
228
+ . AssertLinesCovered ( BuildConfiguration . Debug , 52 , 55 )
229
+ . AssertLinesNotCovered ( BuildConfiguration . Debug , 53 , 54 )
230
+ . AssertLinesCovered ( BuildConfiguration . Release , 52 , 55 )
231
+ . AssertLinesNotCovered ( BuildConfiguration . Release , 53 , 54 ) ;
56
232
}
57
233
}
58
234
finally
0 commit comments