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
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.
No description
1 Reply
Anton Galkin
Anton GalkinOP4h ago
I tried casting the 2 to a uint in MemberData, but for some reason this resulted in an infinite loop, and it said I had 25 failed tests, when testing just 1.

Did you find this page helpful?