Table of Contents

Class TestFixtureSourceAttribute

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

TestCaseSourceAttribute indicates the source to be used to provide test fixture instances for a test class.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class TestFixtureSourceAttribute : NUnitAttribute, 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 string

The name of a static method, property or field that will provide data.

TestFixtureSourceAttribute(Type)

Construct with a Type

public TestFixtureSourceAttribute(Type sourceType)

Parameters

sourceType Type

The type that will provide data

TestFixtureSourceAttribute(Type, string)

Construct with a Type and name

public TestFixtureSourceAttribute(Type sourceType, string sourceName)

Parameters

sourceType Type

The Type that will provide data

sourceName string

The 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

string

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

string

SourceName

The name of a the method, property or fiend to be used as a source

public string SourceName { get; }

Property Value

string

SourceType

A Type to be used as a source

public Type SourceType { get; }

Property Value

Type

Methods

BuildFrom(Type)

Construct one or more TestFixtures from a given Type, using available parameter data.

public IEnumerable<TestSuite> BuildFrom(Type type)

Parameters

type Type

The Type for which fixures are to be constructed.

Returns

IEnumerable<TestSuite>

One or more TestFixtures as TestSuite

GetParametersFor(Type)

Returns a set of ITestFixtureData items for use as arguments to a parameterized test fixture.

public IEnumerable<ITestFixtureData> GetParametersFor(Type type)

Parameters

type Type

The type for which data is needed.

Returns

IEnumerable<ITestFixtureData>