Datapoint(s)Attribute should work on IEnumerable<T> as well as on Arrays

Bug #556971 reported by Charlie Poole
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
High
Charlie Poole
NUnit V2
Fix Released
High
Charlie Poole

Bug Description

[Copied from a thread on the nunit-discuss list]

I am currently playing around with NUnit's concept of theories /
datapoints.
I want to use lists as parameter for a certain Theory(test).

My code is structured like this:

//Preparation of data

 public static List<MySpecialEnum> PrepareList()
 {
           List<MySpecialEnum> settings = new List<MySpecialEnum>();
           foreach (MySpecialEnum setting in
Enum.GetValues(typeof(MySpecialEnum)))
           {
                   settings.Add(setting);
           }
           return settings;
 }

//prepare datapoints
[Datapoints]
 public static List<MySpecialEnum> settingValues = PrepareList();

//create theory
[Theory]
public void CTATheorySample(MySpecialEnum settingVal)
{
 Assume.That(/*everything is okay with settingVal */);
}

When I try to execute the tests, no parameter is visualised in the
NUnit UI and the error "no arguments were provided" is shown in the
NUnit "errors and failures" window!
Do you have any hints or workarounds for me ??
By the way I am using NUnit 2.5.3

Best regards and thanks for any hints,

Bernie

Tags: feature

Related branches

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

The problem with the above is that the DatapointsAttribute is only recognized on an array. It should be extended to allow any
object implementing IEnumerable<T> where T is the type of the argument. Changing the the title to reflect this.

summary: - Theory arguments not initialized correctly
+ DatapointsAttribute should work on IEnumerable<T> as well as arrays
tags: added: feature
Changed in nunit-3.0:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunitv2:
milestone: none → 2.5.5
Changed in nunitv2:
status: Confirmed → Fix Committed
summary: - DatapointsAttribute should work on IEnumerable<T> as well as arrays
+ Datapoint(s)Attribute should work on IEnumerable<T> as well as on Arrays
Changed in nunit-3.0:
status: Confirmed → Triaged
milestone: none → 2.9.4
Changed in nunit-3.0:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
status: Fix Committed → Fix Released
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.