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

UseParameters and params string[] values throws #532

Closed
egil opened this issue May 31, 2022 · 3 comments
Closed

UseParameters and params string[] values throws #532

egil opened this issue May 31, 2022 · 3 comments
Labels
Milestone

Comments

@egil
Copy link

egil commented May 31, 2022

In a data driven test, that use an undetermined number of parameters via eg. params string[] values, UseParameter throws.

The test:

[Theory]
[InlineData("foo")]
[InlineData("foo", "bar")]
[InlineData("foo", "bar", "baz")]
public async Task FooBarBazTest(params string[] values)
{
    var result = PerformAction(values);

    await Verify(result )
        .UseParameters(values);
}

This throws the following exception:

  Message: 
System.Exception : The number of passed in parameters (2) must be fewer than the number of parameters for the method (1).

  Stack Trace: 
ReflectionFileNameBuilder.GetParameterText(MethodInfo method, VerifySettings settings) line 55
ReflectionFileNameBuilder.GetFileNamePrefix(MethodInfo method, Type type, VerifySettings settings, PathInfo pathInfo, String uniqueness) line 32
ReflectionFileNameBuilder.FileNamePrefix(MethodInfo method, Type type, String sourceFile, VerifySettings settings, String uniqueness) line 12
<>c__DisplayClass0_0.<GetVerifier>b__0(String uniqueness) line 15
InnerVerifier.ctor(String sourceFile, VerifySettings settings, GetFileConvention fileConvention) line 17
Verifier.GetVerifier(VerifySettings settings, String sourceFile) line 12
<<Verify>b__0>d.MoveNext() line 29
--- End of stack trace from previous location ---
FooBarBazTest(String[] values) line 1337
--- End of stack trace from previous location ---

Current workaround: UseParameters(string.Join(",", values));

It would be cool if Verify can detect this and string.Join(",", values) for us.

Versions

.net 6
verify: 16.9.0

@egil egil changed the title UseParameters and params string[] values UseParameters and params string[] values throws May 31, 2022
@SimonCropp
Copy link
Member

i didnt even know that was allowed. i will take a look at it

@SimonCropp SimonCropp added this to the 17.0.3 milestone Jun 2, 2022
@SimonCropp SimonCropp added the Bug label Jun 2, 2022
@SimonCropp
Copy link
Member

can u try 17.0.3

@egil
Copy link
Author

egil commented Jun 5, 2022

looks like it works, thanks!

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

No branches or pull requests

2 participants