When I pass a string array to a test function like this:
[TestCase( new string[] { "1", "2", "3" }, 1 )]
[TestCase( new string[] { "54", "508" }, 1 )]
[TestCase( new string[] { "768" }, 2 )]
public void someTest( string[] someStrings, int someNumber ) {
//...
}
The compilation works fine.
But, if I remove integer parameter like the follwoing code snippet shows:
[TestCase( new string[] { "1", "2", "3" } )]
[TestCase( new string[] { "54", "508" } )]
[TestCase( new string[] { "768" } )]
public void someTest( string[] someStrings ) {
//...
}
A compiler error with the message An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
occurs.
I basically get the cause of the error, that an array is not a constant type. But why is the compiler accepting an array, if there is another paramter passed to the test function? It even works, if I put another array inside the TestCase:
[TestCase( new string[] { "1", "2", "3" }, new int[] { 1, 2, 3 } )]
[TestCase( new string[] { "54", "508" }, new int[] { 54, 508 } )]
[TestCase( new string[] { "768" }, new int[] { 768 } )]
public void someTest( string[] someStrings, int[] someNumbers ) {
//...
}