Description
The xUnit code fixer for MemberData against a static field on the class (not a method) converts the attribute to MethodDataSource, despite the input not being a method.
[Theory]
[MemberData(nameof(Search_DateTimeOffsetsData))]
public void TestWithMemberData(int input, int expected)
{
Assert.Equal(expected, input * 3);
}
public static IEnumerable<object[]> Search_DateTimeOffsetsData = new[]
{
new object[] { 1, 42 },
new object[] { 3, 126 },
};
Expected Behavior
Attribute converts to InstanceMethodDataSource, which surprisingly does work against static fields on the test class.
Actual Behavior
Test converts to the following, which produces an error TUnit0004
[Test]
[MethodDataSource(nameof(Search_DateTimeOffsetsData))]
public async Task TestWithMemberData(int input, int expected)
{
await Assert.That(input * 3).IsEqualTo(expected);
}
public static IEnumerable<object[]> Search_DateTimeOffsetsData = new[]
{
new object[] { 1, 42 },
new object[] { 3, 126 },
};
Steps to Reproduce
Run the xUnit fixer against the above xunit code.
TUnit Version
1.14.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
Description
The xUnit code fixer for
MemberDataagainst a static field on the class (not a method) converts the attribute toMethodDataSource, despite the input not being a method.Expected Behavior
Attribute converts to
InstanceMethodDataSource, which surprisingly does work against static fields on the test class.Actual Behavior
Test converts to the following, which produces an error TUnit0004
Steps to Reproduce
Run the xUnit fixer against the above xunit code.
TUnit Version
1.14.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE