ReSharper 2019.1 Help

Code Inspection: NUnit. Test case source must be field, property, or method only

NUnit's TestCaseSource and ValueSource attributes require data source members to be static field, property, or method.

[TestFixture] public sealed class TestCaseSourceTest { static IEnumerable<int> _fieldSource = new[] {1, 2, 3}; static IEnumerable<int> PropertySource => new[] {4, 5, 6}; static IEnumerable<int> MethodSource() => new[] {7, 8, 9}; public event UnhandledExceptionEventHandler OnError { add => throw new NotImplementedException(); remove => throw new NotImplementedException(); } [TestCaseSource(nameof(_fieldSource))] // ok [TestCaseSource(nameof(PropertySource))] // ok [TestCaseSource(nameof(MethodSource))] // ok [TestCaseSource(nameof(OnError))] // Warning: expected field/property/method public void Test1(int x) { Console.WriteLine(x); } }
Last modified: 16 July 2019

See Also