Provides a column of enumeration values as a data source.

Namespace:  MbUnit.Framework
Assembly:  MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.459.0)

Syntax

C#
public class EnumDataAttribute : DataAttribute
Visual Basic (Declaration)
Public Class EnumDataAttribute _
	Inherits DataAttribute

Remarks

Each value from the specified enumeration type is used as input for the data-driven test method.

It is possible to exclude some specific values of the enumeration from the column. Use Exclude or ExcludeArray for that purpose.

Examples

CopyC#
public enum Planet
{
    Mercury,
    Venus,
    Earth,
    Mars,
    Jupiter,
    Saturn,
    Uranus,
    Neptune
}

[TestFixture]
public class MyTestFixture
{
    [Test]
    public void Test([EnumData(typeof(Planet))] Planet planet)
    {
        // This test will run 8 times with all the possible values of
        // the specified enumeration type.
    }

    [Test]
    public void TestWithRestrictions([EnumData(typeof(Planet), Exclude = Planet.Earth)] Planet planet)
    {
        // This test will run only 7 times.
    }
}

Inheritance Hierarchy

See Also