TheoryAttribute does not work with generics

Bug #537914 reported by The Chairman
6
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 TestForArbitraryArray<T>(T[,] array)
{
  // ...
}

NUnit gives a warning saying "No arguments were provided".

Changed in nunitv2:
importance: Undecided → High
status: New → Triaged
tags: added: feature
Revision history for this message
Charlie Poole (charlie.poole) wrote :

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]
        public void TestForAnythingWhatsoevery<T>(T theThing)
        {
             ...
        }

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

Changed in nunitv2:
status: Triaged → Confirmed
importance: High → Undecided
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Postponed to 3.0

affects: nunitv2 → nunit-3.0
tags: added: framework
tags: added: theories
Changed in nunit-3.0:
importance: Undecided → Medium
tags: added: github
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.