Add Enum support to RandomAttribute

Bug #1023084 reported by Tyrel Alastair Hunter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
Wishlist
Charlie Poole
NUnitLite
Fix Released
Wishlist
Tyrel Alastair Hunter

Bug Description

Add support to the Random Attribute to select a random Enum Value from an enumeration

[Test]
public void Test([Random(numberOfRandomValues)] MyEnum value)
{
    //Random generates a Random Value from MyEnum's Values
}

Related branches

Changed in nunitlite:
importance: Undecided → Wishlist
Changed in nunit-3.0:
importance: Undecided → Wishlist
Changed in nunitlite:
assignee: nobody → Tyrel Alastair Hunter (ialastairhunter)
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Tyrel,

Note that Random(int n) is already defined to generate n doubles between 0.0 and 1.0 (SampleType.Raw).

You'll have to add some code to GetData to recognize that the parameter is an enum and change the SampleType to an appropriate IntRange. You can't do it in the constructor, because the parameter is not available at that point.

Charlie

Changed in nunitlite:
status: New → Fix Committed
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Don't use 'Fix Committed' when the fix is only in your private branch. 'Fix Committed' means that people can get the fix by building from trunk.

Changed in nunitlite:
status: Fix Committed → In Progress
Revision history for this message
Tyrel Alastair Hunter (ialastairhunter) wrote : Re: [Bug 1023084] Re: Add Enum support to RandomAttribute

Sorry about that

Sent from my iPhone

On Jul 13, 2012, at 11:15 AM, Charlie Poole <email address hidden> wrote:

> Don't use 'Fix Committed' when the fix is only in your private branch.
> 'Fix Committed' means that people can get the fix by building from
> trunk.
>
> ** Changed in: nunitlite
> Status: Fix Committed => In Progress
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1023084
>
> Title:
> Add Enum support to RandomAttribute
>
> Status in NUnit Test Framework:
> New
> Status in NUnitLite Testing Framework:
> In Progress
>
> Bug description:
> Add support to the Random Attribute to select a random Enum Value from
> an enumeration
>
> [Test]
> public void Test([Random(numberOfRandomValues)] MyEnum value)
> {
> //Random generates a Random Value from MyEnum's Values
> }
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-3.0/+bug/1023084/+subscriptions

Changed in nunitlite:
status: In Progress → Fix Committed
Changed in nunitlite:
milestone: none → 0.8
Changed in nunitlite:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
status: New → Triaged
milestone: none → 2.9.6
Changed in nunit-3.0:
assignee: nobody → Charlie Poole (charlie.poole)
status: Triaged → Fix Committed
Changed in nunit-3.0:
status: Fix Committed → In Progress
status: In Progress → 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.