Class AutoDataAttribute

Namespace: AutoFixture.NUnit2
Assembly: AutoFixture.NUnit2.dll

Provides auto-generated data specimens generated by AutoFixture as an extention to NUnit TestCase attribute.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
[CLSCompliant(false)]
public class AutoDataAttribute : DataAttribute

Inheritance

objectAttributeDataAttributeAutoDataAttribute

Inherited Members

DataAttribute.GetData(MethodInfo), Attribute.GetCustomAttributes(MemberInfo, Type), Attribute.GetCustomAttributes(MemberInfo, Type, bool), Attribute.GetCustomAttributes(MemberInfo), Attribute.GetCustomAttributes(MemberInfo, bool), Attribute.IsDefined(MemberInfo, Type), Attribute.IsDefined(MemberInfo, Type, bool), Attribute.GetCustomAttribute(MemberInfo, Type), Attribute.GetCustomAttribute(MemberInfo, Type, bool), Attribute.GetCustomAttributes(ParameterInfo), Attribute.GetCustomAttributes(ParameterInfo, Type), Attribute.GetCustomAttributes(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(ParameterInfo, bool), Attribute.IsDefined(ParameterInfo, Type), Attribute.IsDefined(ParameterInfo, Type, bool), Attribute.GetCustomAttribute(ParameterInfo, Type), Attribute.GetCustomAttribute(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(Module, Type), Attribute.GetCustomAttributes(Module), Attribute.GetCustomAttributes(Module, bool), Attribute.GetCustomAttributes(Module, Type, bool), Attribute.IsDefined(Module, Type), Attribute.IsDefined(Module, Type, bool), Attribute.GetCustomAttribute(Module, Type), Attribute.GetCustomAttribute(Module, Type, bool), Attribute.GetCustomAttributes(Assembly, Type), Attribute.GetCustomAttributes(Assembly, Type, bool), Attribute.GetCustomAttributes(Assembly), Attribute.GetCustomAttributes(Assembly, bool), Attribute.IsDefined(Assembly, Type), Attribute.IsDefined(Assembly, Type, bool), Attribute.GetCustomAttribute(Assembly, Type), Attribute.GetCustomAttribute(Assembly, Type, bool), Attribute.Equals(object?), Attribute.GetHashCode(), Attribute.Match(object?), Attribute.IsDefaultAttribute(), Attribute.TypeId, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

AutoDataAttribute()

Initializes a new instance of the AutoDataAttribute class.

public AutoDataAttribute()

Remarks

This constructor overload initializes the `Fixture` to an instance of `Fixture`.

AutoDataAttribute(Type)

Initializes a new instance of the AutoDataAttribute class with an IFixture of the supplied type.

[Obsolete("This constructor overload is deprecated, and will be removed in a future version of AutoFixture. If you need to change the behaviour of the [AutoData] attribute, please create a derived attribute class and pass in a customized Fixture via the constructor that takes an IFixture instance.", true)]
public AutoDataAttribute(Type fixtureType)

Parameters

fixtureType Type

The type of the composer.

Exceptions

ArgumentException

fixtureType does not implement IFixture or does not have a default constructor.

AutoDataAttribute(IFixture)

Initializes a new instance of the AutoDataAttribute class with the supplied IFixture.

[Obsolete("This constructor overload is deprecated because it offers poor performance, and will be removed in a future version. Please use the AutoDataAttribute(Func<IFixture> fixtureFactory) overload, so fixture will be constructed only if needed.")]
protected AutoDataAttribute(IFixture fixture)

Parameters

fixture IFixture

The fixture.

AutoDataAttribute(Func<IFixture>)

Initializes a new instance of the AutoDataAttribute class with the supplied fixtureFactory. Fixture will be created on demand using the provided factory.

protected AutoDataAttribute(Func<IFixture> fixtureFactory)

Parameters

fixtureFactory Func<IFixture>

The fixture factory used to construct the fixture.

Properties

Fixture

Gets the fixture used by MethodInfo) to create specimens.

[Obsolete("Fixture is created lazily for the performance efficiency, so this property is deprecated as it activates the fixture immediately. If you need to customize the fixture, do that in the factory method passed to the constructor.")]
public IFixture Fixture { get; }

Property Value

IFixture

FixtureType

Gets the type of Fixture.

[Obsolete("This property is deprecated and will be removed in a future version of AutoFixture. Please use Fixture.GetType() instead.")]
public Type FixtureType { get; }

Property Value

Type

Methods

GetData(MethodInfo)

Returns the data to be used to test the testcase.

public override IEnumerable<object[]> GetData(MethodInfo method)

Parameters

method MethodInfo

The method that is being tested.

Returns

IEnumerable<object[]>

The testcase data generated by Fixture.