ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Code Inspection: NUnit. Incompatible argument type or incorrect argument value

Last modified: 21 July 2022

This inspection notifies you about mismatch of the type of a value that you pass to your test via the TestCase argument and the type of the corresponding parameter in the test method. For example, in the test method below the error is quite obvious:

But sometimes, the error can be harder to spot. For example

In this case, the array will not be created automatically, so the argument must be an array for the test to work correctly:

Note that NUnit will try to convert the value supplied via ExpectedResult before using it in the test, and ReSharper takes this conversion into consideration before issuing the warning. Note also, that NUnit 2.x and NUnit 3 have different value conversion logic.