I have a unit test where I want to pass some arguments into the test method via the TestCase decorator. The argument I need for this is of type ulong but the tests are failing because it doesn't like the argument that is being passed via the TestCase because it is int32 instead of ulong. How do you pass a ulong when it is the same thing as an int anyway, particularly when I am only passing a single-digit value into the method.
[Test] [TestCase(10, 1, 2)] public void MyTestMethod(int quantity, ulong itemId, ulong parentId) { //do stuff }
1 Answer
You can do the same thing that you do when you want to differentiate an integer from a decimal. Instead, you will just put a u after the integer value and this will satisfy the compiler that you are using a long instead of an int.
The following should fix your problem by putting u after the arguments in the TestCase
[Test] [TestCase(10, 1u, 2u)] public void MyTestMethod(int quantity, ulong itemId, ulong parentId) { //do stuff }
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String