File tree 1 file changed +25
-6
lines changed
tests/BenchmarkDotNet.Tests/Validators
1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -298,12 +298,8 @@ public void NonThrowing() { }
298
298
[ Fact ]
299
299
public void NonPublicFieldsWithParamsAreDiscovered ( )
300
300
{
301
- var validationErrors = ExecutionValidator . FailOnError
302
- . Validate ( BenchmarkConverter . TypeToBenchmarks ( typeof ( NonPublicFieldWithParams ) ) )
303
- . ToList ( ) ;
304
-
305
- Assert . NotEmpty ( validationErrors ) ;
306
- Assert . StartsWith ( $ "Member \" { nameof ( NonPublicFieldWithParams . Field ) } \" must be public if it has the [Params]", validationErrors . Single ( ) . Message ) ;
301
+ Assert . Throws < InvalidOperationException > (
302
+ ( ) => ExecutionValidator . FailOnError . Validate ( BenchmarkConverter . TypeToBenchmarks ( typeof ( NonPublicFieldWithParams ) ) ) ) ;
307
303
}
308
304
309
305
public class NonPublicFieldWithParams
@@ -318,6 +314,29 @@ public class NonPublicFieldWithParams
318
314
public void NonThrowing ( ) { }
319
315
}
320
316
317
+ [ Fact ]
318
+ public void NonPublicFieldsWithParamsSourceAreDiscovered ( )
319
+ {
320
+ Assert . Throws < InvalidOperationException > (
321
+ ( ) => ExecutionValidator . FailOnError . Validate ( BenchmarkConverter . TypeToBenchmarks ( typeof ( NonPublicFieldWithParamsSource ) ) ) ) ;
322
+ }
323
+
324
+ public class NonPublicFieldWithParamsSource
325
+ {
326
+ #pragma warning disable CS0649
327
+ [ ParamsSource ( nameof ( Get ) ) ]
328
+ internal int Field ;
329
+ #pragma warning restore CS0649
330
+
331
+ [ Benchmark ]
332
+ public void NonThrowing ( ) { }
333
+
334
+ public IEnumerable < object > Get ( )
335
+ {
336
+ yield return 0 ;
337
+ }
338
+ }
339
+
321
340
[ Fact ]
322
341
public void NonPublicPropertiesWithParamsAreDiscovered ( )
323
342
{
You can’t perform that action at this time.
0 commit comments