1- using Xunit . Sdk ;
2-
3- namespace NRedisStack . Tests ;
4-
5- // TODO(imalinovskiy): Remove this file once tests are migrated to Xunit v3
6-
7- /// Copyright (c) Andrew Arnott. All rights reserved.
8- // Licensed under the Microsoft Public License (Ms-PL).
9- // https://github.com/AArnott/Xunit.SkippableFact/blob/main/src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs
10- // See https://github.com/AArnott/Xunit.SkippableFact/blob/main/LICENSE for full license information.
11-
12- using System . Collections . Generic ;
13- using Validation ;
14- using Xunit . Abstractions ;
15-
16- /// <summary>
17- /// Patched TestCase discoverer to support SkipIfRedisAttribute.
18- /// </summary>
19- public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer
20- {
21- /// <summary>
22- /// The diagnostic message sink provided to the constructor.
23- /// </summary>
24- private readonly IMessageSink diagnosticMessageSink ;
25-
26- /// <summary>
27- /// The complex theory discovery process that we wrap.
28- /// </summary>
29- private readonly TheoryDiscoverer theoryDiscoverer ;
30-
31- /// <summary>
32- /// Initializes a new instance of the <see cref="SkippableTheoryDiscoverer"/> class.
33- /// </summary>
34- /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages.</param>
35- public SkippableTheoryDiscoverer ( IMessageSink diagnosticMessageSink )
36- {
37- this . diagnosticMessageSink = diagnosticMessageSink ;
38- this . theoryDiscoverer = new TheoryDiscoverer ( diagnosticMessageSink ) ;
39- }
40-
41- /// <inheritdoc />
42- public virtual IEnumerable < IXunitTestCase > Discover ( ITestFrameworkDiscoveryOptions discoveryOptions , ITestMethod testMethod , IAttributeInfo factAttribute )
43- {
44- Requires . NotNull ( factAttribute , nameof ( factAttribute ) ) ;
45- string [ ] skippingExceptionNames = new [ ] { "Xunit.SkippableFact.SkipException" } ;
46- TestMethodDisplay defaultMethodDisplay = discoveryOptions . MethodDisplayOrDefault ( ) ;
47-
48- IEnumerable < IXunitTestCase > ? basis = this . theoryDiscoverer . Discover ( discoveryOptions , testMethod , factAttribute ) ;
49- foreach ( IXunitTestCase ? testCase in basis )
50- {
51- if ( testCase is XunitTheoryTestCase )
52- {
53- yield return new SkippableTheoryTestCase ( skippingExceptionNames , this . diagnosticMessageSink , defaultMethodDisplay , discoveryOptions . MethodDisplayOptionsOrDefault ( ) , testCase . TestMethod ) ;
54- }
55- else
56- {
57- yield return new SkippableFactTestCase ( skippingExceptionNames , this . diagnosticMessageSink , defaultMethodDisplay , discoveryOptions . MethodDisplayOptionsOrDefault ( ) , testCase . TestMethod , testCase . TestMethodArguments ) ;
58- }
59- }
60- }
61- }
0 commit comments