MemberData must reference a static member
This rule is triggered when your [MemberData]
attribute points to a non-static
member.
[MemberData]
attributes may only point at static
members, or else they will fail at runtime.
To fix a violation of this rule, make the data member static
.
using System.Collections.Generic;
using Xunit;
public class xUnit1017
{
public IEnumerable<object[]> TestData;
[Theory]
[MemberData(nameof(TestData))]
public void TestMethod(string greeting, int age) { }
}
using System.Collections.Generic;
using Xunit;
public class xUnit1017
{
public static IEnumerable<object[]> TestData;
[Theory]
[MemberData(nameof(TestData))]
public void TestMethod(string greeting, int age) { }
}