NUnit cannot recognise a TestCase when it contains an Nullable Array

1.5k Views Asked by At

I have test like this:

[Test]
[TestCase(new RequestStatus?[] {RequestStatus.Created, null, RequestStatus.Complete, null})]
public void MyClass_MyMethod( RequestStatus?[] testCaseRequest )
{
  ...
}

Nuint doesn't recognise Nullable Array as TestCase param. I got this:

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

1

There are 1 best solutions below

0
On

You may use params as a method argument:

[TestCase(RequestStatus.Created, null, RequestStatus.Complete, null)]
public void MyClass_MyMethod(params RequestStatus?[] requestStatus)
{
    // ...
}