Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodDataSource expects ValueTuple on 8 arguments #1538

Open
dev-in-disguise opened this issue Jan 10, 2025 · 1 comment
Open

MethodDataSource expects ValueTuple on 8 arguments #1538

dev-in-disguise opened this issue Jan 10, 2025 · 1 comment

Comments

@dev-in-disguise
Copy link

Hi Thom!
I'm having the following test that uses MethodDataSource which points to a method that returns a tuple of the values I'm expecting as arguments.

[Test]
[MethodDataSource(nameof(T5_DeconstructTestDataSource))]
public async Task T5_Deconstruct_Should_ReturnAllResults(bool expectedSuccess, string? expectedError,
    string? expectedT0, string? expectedT1, string? expectedT2, string? expectedT3, string? expectedT4, string? expectedT5)
{
    
}

public static
    IEnumerable<(bool success, string? expectedError, string? expectedT0, string? expectedT1, string? expectedT2,
        string? expectedT3, string? expectedT4, string? expectedT5)>
    T5_DeconstructTestDataSource()
{
    yield return (true, null, "This is a success", null, null, null, null, null);
    yield return (false, "This is a failure", null, null, null, null, null, null);
}

This leads to the following error (plus 3 additional ones for the generated test code from TUnit that basically tell the same thing):

TUnit0001: Attribute argument types 'bool, string?, string?, string?, string?, string?, string?, System. ValueTuple<string?>' don't match method parameter types 'bool, string?, string?, string?, string?, string?, string?, string?'

Why is there suddenly a ValueTuple<string?> assumed by TUnit? Is there a hard limit for how many types TUnit supports?

By the way if I add further arguments to my test method and the data source they get then added to the ValueTuple.

Of course I could create an own type for the test data but still it would be great if this edge case could be either documented or a fix for it discovered.

Thank you so much Thom in case you get once again to a solution!

@thomhurst
Copy link
Owner

Hey @dev-in-disguise,

This is a weird one indeed. Looks like Roslyn is giving me the wrong types when inspecting them!?

I've raised an issue with them: dotnet/roslyn#76714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants