-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
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?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working