File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed
tests/BenchmarkDotNet.Tests/Validators Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -298,12 +298,8 @@ public void NonThrowing() { }
298298 [ Fact ]
299299 public void NonPublicFieldsWithParamsAreDiscovered ( )
300300 {
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 ) ) ) ) ;
307303 }
308304
309305 public class NonPublicFieldWithParams
@@ -318,6 +314,29 @@ public class NonPublicFieldWithParams
318314 public void NonThrowing ( ) { }
319315 }
320316
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+
321340 [ Fact ]
322341 public void NonPublicPropertiesWithParamsAreDiscovered ( )
323342 {
You can’t perform that action at this time.
0 commit comments