views:

112

answers:

1

I'm trying to make use of the TheoryAttribute, introduced in NUnit 2.5. Everything works fine as long as the arguments are of a defined type:

[Datapoint]
public double[,] Array2X2 = new double[,] { { 1, 0 }, { 0, 1 } };

[Theory]
public void TestForArbitraryArray(double[,] array)
{
  // ...
}

It does not work, when I use generics:

[Datapoint]
public double[,] Array2X2 = new double[,] { { 1, 0 }, { 0, 1 } };

[Theory]
public void TestForArbitraryArray<T>(T[,] array)
{
  // ...
}

NUnit gives a warning saying No arguments were provided. Why is that?

+1  A: 

I think it's because Datapoints have to match Types with the DatapointAttribute. From the NUnit help on Datapoints:

When a Theory is loaded, NUnit creates arguments for each of its parameters by using any fields of the same type as the parameter annotated with the DatapointAttribute. In addition, elements of arrays of the required type annotated with the DatapointsAttribute are also used.

Paddyslacker