Class AutoDataAttribute
Namespace: AutoFixture.Xunit
Assembly: AutoFixture.Xunit.dll
Provides auto-generated data specimens generated by AutoFixture as an extension to xUnit.net's Theory attribute.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
[CLSCompliant(false)]
public class AutoDataAttribute : DataAttributeInheritance
DataAttribute ← AutoDataAttribute
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
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 Type%5b%5d) 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
Methods
GetData(MethodInfo, Type[])
Returns the data to be used to test the theory.
public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest, Type[] parameterTypes)Parameters
methodUnderTest MethodInfo
The method that is being tested.
parameterTypes Type[]
The types of the parameters for the test method.
Returns
The theory data generated by Fixture.