I have a test-method as follows:
[TestCase(new string[] { "1", "2", "5" }, Result = true)]
bool AllocateIDsTest1(IEnumerable<string> expected)
{
var target = ...
var actual = target.AllocateIDs(expected);
return actual.SequenceEqual(expected);
}
However I get a compiler-error:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.
Probably the compiler can´t distinguish between the following constructors:
TestCase(params object[] args, Named Parameters);
and
TestCase(object ob1, Named Paramaters);
because new string[] { "1", "2", "5" }
can be resolved to both params object[]
and object
.
From this post I know that a string-array should be possible to pass as compile-constants.
How can I provide an array of strings to a TestCase
?