Show / Hide Table of Contents

Interface IDataDiscoverer

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).

Namespace: Xunit.Sdk
Assembly: xunit.core.dll
Syntax
public interface IDataDiscoverer

Methods

| Improve this Doc View Source

GetData(IAttributeInfo, IMethodInfo)

Returns the data to be used to test the theory.

Declaration
IEnumerable<object[]> GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
Parameters
Type Name Description
IAttributeInfo dataAttribute

The data attribute being discovered

IMethodInfo testMethod

The method that is being tested/discovered

Returns
Type Description
IEnumerable<Object[]>

The theory data (or null during discovery, if not enough information is available to enumerate the data)

Remarks

This will be called during discovery, at which point the testMethod may or may not be backed by reflection (i.e., implementing ). 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 . At this time, you must return the actual data, and returning null is not legal.

| Improve this Doc View Source

SupportsDiscoveryEnumeration(IAttributeInfo, IMethodInfo)

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.

Declaration
bool SupportsDiscoveryEnumeration(IAttributeInfo dataAttribute, IMethodInfo testMethod)
Parameters
Type Name Description
IAttributeInfo dataAttribute
IMethodInfo testMethod
Returns
Type Description
Boolean
  • Improve this Doc
  • View Source
Back to top Generated by DocFX