Skip to content

Commit

Permalink
Work around PreenumerateTheories
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrandenburg committed Dec 12, 2018
1 parent 3c2b275 commit a80aff3
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ public ConditionalTheoryDiscoverer(IMessageSink diagnosticMessageSink)
{
}

private sealed class OptionsWithPreEnumerationEnabled : ITestFrameworkDiscoveryOptions
{
private const string PreEnumerateTheories = "xunit.discovery.PreEnumerateTheories";

private readonly ITestFrameworkDiscoveryOptions _original;

public OptionsWithPreEnumerationEnabled(ITestFrameworkDiscoveryOptions original)
=> _original = original;

public TValue GetValue<TValue>(string name)
=> (name == PreEnumerateTheories) ? (TValue)(object)true : _original.GetValue<TValue>(name);

public void SetValue<TValue>(string name, TValue value)
=> _original.SetValue(name, value);
}

public override IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
=> base.Discover(new OptionsWithPreEnumerationEnabled(discoveryOptions), testMethod, theoryAttribute);

protected override IEnumerable<IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
{
var skipReason = testMethod.EvaluateSkipConditions();
Expand Down

0 comments on commit a80aff3

Please sign in to comment.