Skip to content

Commit 38a183e

Browse files
committed
Add test
1 parent eaa280f commit 38a183e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/BenchmarkDotNet.Tests/Validators/ExecutionValidatorTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,33 @@ public class NonPublicFieldWithParams
317317
public void NonThrowing() { }
318318
}
319319

320+
[Fact]
321+
public void NonPublicFieldsWithParamsSourceAreDiscovered()
322+
{
323+
var validationErrors = ExecutionValidator.FailOnError
324+
.Validate(BenchmarkConverter.TypeToBenchmarks(typeof(NonPublicFieldWithParamsSource)))
325+
.ToList();
326+
327+
Assert.NotEmpty(validationErrors);
328+
Assert.StartsWith($"Member \"{nameof(NonPublicFieldWithParamsSource.Field)}\" must be public if it has the [ParamsSource]", validationErrors.Single().Message);
329+
}
330+
331+
public class NonPublicFieldWithParamsSource
332+
{
333+
#pragma warning disable CS0649
334+
[ParamsSource(nameof(Get))]
335+
internal int Field;
336+
#pragma warning restore CS0649
337+
338+
[Benchmark]
339+
public void NonThrowing() { }
340+
341+
public IEnumerable<object> Get()
342+
{
343+
yield return 0;
344+
}
345+
}
346+
320347
[Fact]
321348
public void NonPublicPropertiesWithParamsAreDiscovered()
322349
{

0 commit comments

Comments
 (0)