When using the TestCaseAttribute or TestCaseSourceAttribute on a test-method, the test-method is allowed to be generic, as long as the testcase-arguments provided for each testcase can be used by NUnit to resolve all the open generic type parameters of the test-method to generate and run a new test.
However, NUnit fails to resolve the generic type parameter TValue when that parameter is constrained to be a struct and the actual method parameter is declared as a Nullable and the provided testcase-arguments are either of type TValue or Nullable. For example, given the following test-method, NUnit will fail to run the method with the message 'Unable to determine type arguments for method':
[TestCase(0)]
public void SomeTest<TValue>(TValue? value) where TValue : struct
{
...
}
The expected behavior is, of course, that NUnit will be able to resolve the desired type of TValue to Int32 and then pass the test-case argument (0) as a value for the method parameter.
This bug was discovered using NUnit 4.1.0 but is still present in NUnit 4.2.2.
When using the TestCaseAttribute or TestCaseSourceAttribute on a test-method, the test-method is allowed to be generic, as long as the testcase-arguments provided for each testcase can be used by NUnit to resolve all the open generic type parameters of the test-method to generate and run a new test.
However, NUnit fails to resolve the generic type parameter TValue when that parameter is constrained to be a struct and the actual method parameter is declared as a Nullable and the provided testcase-arguments are either of type TValue or Nullable. For example, given the following test-method, NUnit will fail to run the method with the message 'Unable to determine type arguments for method':
The expected behavior is, of course, that NUnit will be able to resolve the desired type of TValue to Int32 and then pass the test-case argument (0) as a value for the method parameter.
This bug was discovered using NUnit 4.1.0 but is still present in NUnit 4.2.2.