TheoryAttribute does not work with generics
Bug #537914 reported by
The Chairman
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Confirmed
|
Medium
|
Unassigned |
Bug Description
Setting: NUnit 2.5.3, Console runner, .NET 3.5
TheoryAttribute does not work with generics:
[Datapoint]
public double[,] Array2X2 = new double[,] { { 1, 0 }, { 0, 1 } };
[Theory]
public void TestForArbitrar
{
// ...
}
NUnit gives a warning saying "No arguments were provided".
Changed in nunitv2: | |
importance: | Undecided → High |
status: | New → Triaged |
tags: | added: feature |
Changed in nunit-3.0: | |
importance: | Undecided → Medium |
tags: | added: github |
To post a comment you must log in.
That's understandable, because the Datapoints are required to exactly match the
argument type and double[,] is not an _exact_ match for T[,], even though it would
a proper match when calling the method. The problem is that there can never be
an exact match for this argument, since Datapoints will always be of some
particular type rather than generic.
I'm inclined not to support this. I'm at a loss to think of a good use case and it
seems to open up the possibility of a Theory that eats up any datapoint whatsoever,
like this one...
[Theory] Whatsoevery< T>(T theThing)
public void TestForAnything
{
...
}
Can you explain why this is useful? I've also posted a question about it on the
nunit-discuss list, so you can respond there if you're a member.
Charlie