xUnit.net
Public Member Functions | List of all members
Xunit.Sdk.IDataDiscoverer Interface Reference

This class is responsible for discovering the data available in an implementation of DataAttribute. The discovery process may not always have access to reflection (i.e., running in Resharper), so the discoverer must make a best effort to return data, but may return null when there is not enough information available (for example, if reflection is required to answer the question). More...

Inheritance diagram for Xunit.Sdk.IDataDiscoverer:
Xunit.Sdk.DataDiscoverer Xunit.Sdk.InlineDataDiscoverer Xunit.Sdk.MemberDataDiscoverer

Public Member Functions

IEnumerable< object[]> GetData (IAttributeInfo dataAttribute, IMethodInfo testMethod)
 Returns the data to be used to test the theory. More...
 
bool SupportsDiscoveryEnumeration (IAttributeInfo dataAttribute, IMethodInfo testMethod)
 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. More...
 

Detailed Description

This class is responsible for discovering the data available in an implementation of DataAttribute. The discovery process may not always have access to reflection (i.e., running in Resharper), so the discoverer must make a best effort to return data, but may return null when there is not enough information available (for example, if reflection is required to answer the question).

Member Function Documentation

◆ GetData()

IEnumerable<object[]> Xunit.Sdk.IDataDiscoverer.GetData ( IAttributeInfo  dataAttribute,
IMethodInfo  testMethod 
)

Returns the data to be used to test the theory.

This will be called during discovery, at which point the testMethod may or may not be backed by reflection (i.e., implementing IReflectionMethodInfo). If the data is not available because reflection is required, then you may return null to inform xUnit that the quantity of data is unknown at this point. When the tests are run, if you returned back null during discovery, then this method will be called again to retrieve the data, this time guaranteed to provide an implementation of IReflectionMethodInfo. At this time, you must return the actual data, and returning null is not legal.

Parameters
dataAttributeThe data attribute being discovered
testMethodThe method that is being tested/discovered
Returns
The theory data (or null during discovery, if not enough information is available to enumerate the data)

Implemented in Xunit.Sdk.DataDiscoverer, and Xunit.Sdk.InlineDataDiscoverer.

◆ SupportsDiscoveryEnumeration()

bool Xunit.Sdk.IDataDiscoverer.SupportsDiscoveryEnumeration ( IAttributeInfo  dataAttribute,
IMethodInfo  testMethod 
)

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.

Implemented in Xunit.Sdk.DataDiscoverer, Xunit.Sdk.InlineDataDiscoverer, and Xunit.Sdk.MemberDataDiscoverer.


The documentation for this interface was generated from the following file: