I'm currently building a Test Project and I need to pass several arguments to the test function. Because I need to call the test function with different parameter sets I decided to use ms-test with the [DataTestMethod]. Now I need to pass jagged arrays as Parameters to the function. But I don't get it to work. The call for TestMethod1 is working. The call for TestMethod2 is not working as it is not successfully compiling.
CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject2
{
[TestClass]
public class UnitTest1
{
[DataTestMethod]
[DataRow(new int[] { })]
public void TestMethod1(int[] values)
{
}
[DataTestMethod]
[DataRow(new int [][] { } )]
public void TestMethod2(int[][] values)
{
}
}
}
Does anyone has any suggestion to get this working? Sadly I need to use some kind of two dimension data type because I need to pass information about two loops inside of the test function. I can't use the params keyword because I need two of this jagged arrays in the test function.
Regards White
int[][]is not a multi-dimensional array but a jagged array.int[,]is a multi-dimensional array of rank 2Attributeparameter.