Class TestFixtureSourceAttribute
Identifies the source used to provide test fixture instances for a test class.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class TestFixtureSourceAttribute : NUnitAttribute, IFixtureBuilder2, IFixtureBuilder
- Inheritance
-
TestFixtureSourceAttribute
- Implements
- Inherited Members
Constructors
TestFixtureSourceAttribute(string)
Construct with the name of the method, property or field that will provide data
public TestFixtureSourceAttribute(string sourceName)
Parameters
sourceName
stringThe name of a static method, property or field that will provide data.
TestFixtureSourceAttribute(Type)
Construct with a Type
public TestFixtureSourceAttribute(Type sourceType)
Parameters
sourceType
TypeThe type that will provide data
TestFixtureSourceAttribute(Type, string)
Construct with a Type and name
public TestFixtureSourceAttribute(Type sourceType, string sourceName)
Parameters
sourceType
TypeThe Type that will provide data
sourceName
stringThe name of a static method, property or field that will provide data.
Fields
MUST_BE_STATIC
Error message string is public so the tests can use it
public const string MUST_BE_STATIC = "The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method."
Field Value
Properties
Category
Gets or sets the category associated with every fixture created from this attribute. May be a single category or a comma-separated list.
public string? Category { get; set; }
Property Value
SourceName
The name of a the method, property or field to be used as a source
public string? SourceName { get; }
Property Value
SourceType
A Type to be used as a source
public Type? SourceType { get; }
Property Value
Methods
BuildFrom(ITypeInfo)
Builds any number of test fixtures from the specified type.
public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo)
Parameters
typeInfo
ITypeInfoThe TypeInfo for which fixtures are to be constructed.
Returns
BuildFrom(ITypeInfo, IPreFilter)
Builds any number of test fixtures from the specified type.
public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter)
Parameters
typeInfo
ITypeInfoThe TypeInfo for which fixtures are to be constructed.
filter
IPreFilterPreFilter used to select methods as tests.
Returns
GetParametersFor(Type)
Returns a set of ITestFixtureData items for use as arguments to a parameterized test fixture.
public IEnumerable<ITestFixtureData> GetParametersFor(Type sourceType)
Parameters
sourceType
TypeThe type for which data is needed.