Class DataAttribute
- Namespace
- Xunit.v3
- Assembly
- xunit.v3.core.dll
Abstract attribute which represents a based implementation of IDataAttribute. Data source providers derive from this attribute and implement GetData(MethodInfo, DisposalTracker) to return the data for the theory.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class DataAttribute : Attribute, IDataAttribute
- Inheritance
-
DataAttribute
- Implements
- Derived
- Inherited Members
Properties
- Explicit
Sets a value that determines whether the data rows provided by this data provider should be considered explicit or not. If
true
, then the data rows will all be considered explicit; iffalse
, then the data rows will all be considered not explicit; if unset, then the data rows will inherit their explicitness from Explicit.
- ExplicitAsNullable
Gettable as a nullable value since .NET Framework does not permit attributes to have nullable value types for settable properties.
- Label
Gets the label to use for the data row. This value is used to help format the display name of the test.
- Skip
Gets a skip reason for all the data rows provided by this data provider. If not
null
, then all rows will be skipped with the given reason; ifnull
, then the rows will inherit their skip reason from Skip.
- SkipType
Gets the type to retrieve SkipUnless or SkipWhen from. If not set, then the property will be retrieved from the unit test class.
- SkipUnless
Gets the name of a public static property on the test class which returns
bool
to indicate whether the test should be skipped (false
) or not (true
).
- SkipWhen
Gets the name of a public static property on the test class which returns
bool
to indicate whether the test should be skipped (true
) or not (false
).
- TestDisplayName
Gets the test display name for the test (replacing the default behavior, which would be to use DisplayName, or falling back to generating display names based on TestMethodDisplay and TestMethodDisplayOptions).
- Timeout
Sets a value to determine if the data rows provided by this data provider should include a timeout (in milliseconds). If greater than zero, the data rows will have the given timeout; if zero or less, the data rows will not have a timeout; if unset, the data rows will inherit their timeout from Timeout.
- TimeoutAsNullable
Gettable as a nullable value since .NET Framework does not permit attributes to have nullable value types for settable properties.
- Traits
Gets a set of traits for the associated data. The data is provided as an array of string values that are alternating keys and values (e.g.,
["key1", "value1", "key2", "value2"]
).
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.
- GetData(MethodInfo, DisposalTracker)
Returns the data to be used to test the theory.
- 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 returnfalse
.