aboutsummaryrefslogtreecommitdiff
path: root/src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs')
-rw-r--r--src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs b/src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs
new file mode 100644
index 00000000..bf850cba
--- /dev/null
+++ b/src/internal/WixInternal.TestSupport/XunitExtensions/SkippableTheoryDiscoverer.cs
@@ -0,0 +1,41 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixInternal.TestSupport.XunitExtensions
4{
5 using System.Collections.Generic;
6 using Xunit.Abstractions;
7 using Xunit.Sdk;
8
9 public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer
10 {
11 private IMessageSink DiagnosticMessageSink { get; }
12 private TheoryDiscoverer TheoryDiscoverer { get; }
13
14 public SkippableTheoryDiscoverer(IMessageSink diagnosticMessageSink)
15 {
16 this.DiagnosticMessageSink = diagnosticMessageSink;
17
18 this.TheoryDiscoverer = new TheoryDiscoverer(diagnosticMessageSink);
19 }
20
21 public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
22 {
23 var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
24 var defaultMethodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault();
25
26 // Unlike fact discovery, the underlying algorithm for theories is complex, so we let the theory discoverer
27 // do its work, and do a little on-the-fly conversion into our own test cases.
28 foreach (var testCase in this.TheoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute))
29 {
30 if (testCase is XunitTheoryTestCase)
31 {
32 yield return new SkippableTheoryTestCase(this.DiagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testCase.TestMethod);
33 }
34 else
35 {
36 yield return new SkippableFactTestCase(this.DiagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testCase.TestMethod, testCase.TestMethodArguments);
37 }
38 }
39 }
40 }
41}