Class ClassDataAttribute
- Namespace
- Xunit
- Assembly
- xunit.v3.core.dll
Provides a data source for a data theory, with the data coming from a class which must implement IEnumerable<object?[]>.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class ClassDataAttribute : DataAttribute, IDataAttribute
- Inheritance
-
ClassDataAttribute
- Implements
- Inherited Members
Constructors
ClassDataAttribute(Type)
Provides a data source for a data theory, with the data coming from a class which must implement IEnumerable<object?[]>.
public ClassDataAttribute(Type @class)
Parameters
classTypeThe class that provides the data.
Properties
Class
Gets the type of the class that provides the data.
public Type Class { get; }
Property Value
Methods
ConvertDataRow(object)
Converts an item yielded by the data attribute to an ITheoryDataRow, for return
from GetData(MethodInfo, DisposalTracker). Items yielded will typically be object[], ITheoryDataRow,
or System.Runtime.CompilerServices.ITuple, but this override will allow derived
attribute types to support additional data items. If the data item cannot be converted, this method
will throw ArgumentException.
protected override ITheoryDataRow ConvertDataRow(object dataRow)
Parameters
dataRowobjectAn item yielded from the data member.
Returns
- ITheoryDataRow
An ITheoryDataRow suitable for return from GetData(MethodInfo, DisposalTracker).
Exceptions
- ArgumentException
Thrown when
dataRowdoes not point to a valid data row (must be compatible withobject[]or ITheoryDataRow).
GetData(MethodInfo, DisposalTracker)
Returns the data to be used to test the theory.
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)
Parameters
testMethodMethodInfoThe test method the data attribute is attached to
disposalTrackerDisposalTrackerThe disposal tracker used to dispose the data
Returns
SupportsDiscoveryEnumeration()
Returns true if the data attribute supports enumeration during
discovery; false otherwise. Data attributes with expensive computational
costs and/or randomized data sets should return false.
public override bool SupportsDiscoveryEnumeration()