C#C
C#3mo ago
Anton Galkin

xUnit `MemeberData` function with parameters raises a type error

I am trying to run tests, where I generate a varying number of inputs for my tests. Please help me achieve this. I have been unsuccessful with my current implementation (image), and I am willing to hear how I could improve or redo this. I have no problem starting from scratch.

See code attached in image.

When I run this test however, I get an error message saying that the parameter 2 was not compatible with the type of the value that is passed to GetNTuples. The specific type error I when I try to run the test is:
Starting test run
[Failed] Calculator.Core.Tests.TestExactUint.Equality
    Message:
        System.ArgumentException : Could not find public static member (property, field, or method) named 'GetNTuples' on Calculator.Core.Tests.TestExactUint with parameter types: System.Int32

==== Summary ====
Failed!  - Failed:    1, Passed:    0, Skipped:    0, Total:    1, Duration: 175ms


Do keep in mind I had to use that pragma because the analyzer was bothering me. It resulted on the [MemberData(...)] line. I also tried to use TheoryData but I just got a different analyzer warning I didn't know how to resolve, so I ended up sticking with the the suppression of the first warning, which is what you see now. Evidently, this warning indicates something, but I don't know what.
Screenshot_From_2025-10-05_01-21-40.png
Was this page helpful?