/// <summary> /// Discover test cases from a test method. By default, if the method is generic, or /// it contains arguments, returns a single <see cref="ExecutionErrorTestCase"/>; /// otherwise, it returns the result of calling <see cref="CreateTestCase"/>. /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="factAttribute">The fact attribute attached to the test method.</param> /// <returns>Returns zero or more test cases represented by the test method.</returns> public virtual IEnumerable <IXunitTestCase> Discover( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo factAttribute) { Guard.ArgumentNotNull(nameof(discoveryOptions), discoveryOptions); Guard.ArgumentNotNull(nameof(testMethod), testMethod); Guard.ArgumentNotNull(nameof(factAttribute), factAttribute); IXunitTestCase testCase; if (testMethod.Method.GetParameters().Any()) { testCase = ErrorTestCase(discoveryOptions, testMethod, "[Fact] methods are not allowed to have parameters. Did you mean to use [Theory]?"); } else if (testMethod.Method.IsGenericMethodDefinition) { testCase = ErrorTestCase(discoveryOptions, testMethod, "[Fact] methods are not allowed to be generic."); } else { testCase = CreateTestCase(discoveryOptions, testMethod, factAttribute); } return(new[] { testCase }); }
/// <summary> /// Initializes a new instance of the <see cref="ExecutionErrorTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method.</param> /// <param name="errorMessage">The error message to report for the test.</param> public ExecutionErrorTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string errorMessage) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.errorMessage = Guard.ArgumentNotNull(errorMessage); }
/// <summary> /// Initializes a new instance of the <see cref="ExecutionErrorTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method.</param> /// <param name="errorMessage">The error message to report for the test.</param> public ExecutionErrorTestCase( _IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string errorMessage) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.errorMessage = Guard.ArgumentNotNull(nameof(errorMessage), errorMessage); }
ExecutionErrorTestCase ErrorTestCase( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, string message) => new ExecutionErrorTestCase( DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, message );
protected override Task <RunSummary> RunTestMethodAsync( _ITestMethod testMethod, _IReflectionMethodInfo method, IEnumerable <IXunitTestCase> testCases, object?[] constructorArguments) { ConstructorArguments.Add(constructorArguments); RunTestMethodAsync_AggregatorResult = Aggregator.ToException(); return(Task.FromResult(new RunSummary())); }
/// <summary> /// Initializes a new instance of the <see cref="XunitDelayEnumeratedTheoryTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The method under test.</param> /// <param name="skipReason">The optional reason for skipping the test; if not provided, will be read from the <see cref="FactAttribute"/>.</param> /// <param name="traits">The optional traits list; if not provided, will be read from trait attributes.</param> /// <param name="timeout">The optional timeout (in milliseconds); if not provided, will be read from the <see cref="FactAttribute"/>.</param> /// <param name="uniqueID">The optional unique ID for the test case; if not provided, will be calculated.</param> public XunitDelayEnumeratedTheoryTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string?skipReason = null, Dictionary <string, List <string> >?traits = null, int?timeout = null, string?uniqueID = null) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, null, skipReason, traits, timeout, uniqueID, null) { }
/// <summary> /// Initializes a new instance of the <see cref="XunitPreEnumeratedTheoryTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The arguments for the test method.</param> /// <param name="skipReason">The optional reason for skipping the test; if not provided, will be read from the <see cref="FactAttribute"/>.</param> /// <param name="traits">The optional traits list; if not provided, will be read from trait attributes.</param> /// <param name="timeout">The optional timeout (in milliseconds); if not provided, will be read from the <see cref="FactAttribute"/>.</param> /// <param name="uniqueID">The optional unique ID for the test case; if not provided, will be calculated.</param> /// <param name="displayName">The optional display name for the test</param> public XunitPreEnumeratedTheoryTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, object?[] testMethodArguments, string?skipReason = null, Dictionary <string, List <string> >?traits = null, int?timeout = null, string?uniqueID = null, string?displayName = null) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments, skipReason, traits, timeout, uniqueID, displayName) { }
/// <summary> /// Creates test cases for the entire theory. This is used when one or more of the theory data items /// are not serializable, or if the user has requested to skip theory pre-enumeration. By default, /// returns a single instance of <see cref="XunitDelayEnumeratedTheoryTestCase"/>, which performs the data discovery /// at runtime. /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <returns>The test case</returns> protected virtual ValueTask <IReadOnlyCollection <IXunitTestCase> > CreateTestCasesForTheory( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute) { var testCase = new XunitDelayEnumeratedTheoryTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod ); return(new(new[] { testCase })); }
/// <summary> /// Creates test cases for the entire theory. This is used when one or more of the theory data items /// are not serializable, or if the user has requested to skip theory pre-enumeration. By default, /// returns a single instance of <see cref="XunitDelayEnumeratedTheoryTestCase"/>, which performs the data discovery /// at runtime. /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <returns>The test case</returns> protected virtual IEnumerable <IXunitTestCase> CreateTestCasesForTheory( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute) { var testCase = new XunitDelayEnumeratedTheoryTestCase( DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod ); return(new[] { testCase }); }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestMethodRunnerContext"/> record. /// </summary> public XunitTestMethodRunnerContext( _ITestClass testClass, _ITestMethod testMethod, _IReflectionTypeInfo @class, _IReflectionMethodInfo method, IReadOnlyCollection <IXunitTestCase> testCases, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, object?[] constructorArguments) : base(testClass, testMethod, @class, method, testCases, messageBus, aggregator, cancellationTokenSource) { ConstructorArguments = constructorArguments; }
protected override Task <RunSummary> RunTestMethodAsync( _ITestMethod testMethod, _IReflectionMethodInfo method, IEnumerable <_ITestCase> testCases, object?[] constructorArguments) { if (cancelInRunTestMethodAsync) { CancellationTokenSource.Cancel(); } RunTestMethodAsync_AggregatorResult = Aggregator.ToException(); MethodsRun.Add(Tuple.Create(method, testCases, constructorArguments)); return(Task.FromResult(result)); }
/// <summary> /// Creates a single <see cref="XunitTestCase"/> for the given test method. /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method.</param> /// <param name="factAttribute">The attribute that decorates the test method.</param> protected virtual IXunitTestCase CreateTestCase( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo factAttribute) { Guard.ArgumentNotNull(discoveryOptions); Guard.ArgumentNotNull(testMethod); Guard.ArgumentNotNull(factAttribute); return(new XunitTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod )); }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestMethodRunner"/> class. /// </summary> /// <param name="testMethod">The test method to be run.</param> /// <param name="class">The test class that contains the test method.</param> /// <param name="method">The test method that contains the tests to be run.</param> /// <param name="testCases">The test cases to be run.</param> /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param> /// <param name="messageBus">The message bus to report run status to.</param> /// <param name="aggregator">The exception aggregator used to run code and collect exceptions.</param> /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param> /// <param name="constructorArguments">The constructor arguments for the test class.</param> public XunitTestMethodRunner( _ITestMethod testMethod, _IReflectionTypeInfo @class, _IReflectionMethodInfo method, IEnumerable <IXunitTestCase> testCases, _IMessageSink diagnosticMessageSink, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, object?[] constructorArguments) : base(testMethod, @class, method, testCases, messageBus, aggregator, cancellationTokenSource) { this.constructorArguments = Guard.ArgumentNotNull(nameof(constructorArguments), constructorArguments); this.diagnosticMessageSink = Guard.ArgumentNotNull(nameof(diagnosticMessageSink), diagnosticMessageSink); }
/// <summary> /// Creates test cases for a skipped theory. By default, returns a single instance of <see cref="XunitTestCase"/> /// (which inherently discovers the skip reason via the fact attribute). /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <param name="skipReason">The skip reason that decorates <paramref name="theoryAttribute"/>.</param> /// <returns>The test cases</returns> protected virtual ValueTask <IReadOnlyCollection <IXunitTestCase> > CreateTestCasesForSkippedTheory( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute, string skipReason) { // TODO: Skip reason should be passed down into the test case var testCase = new XunitTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod ); return(new(new[] { testCase })); }
/// <summary> /// Initializes a new instance of the <see cref="CulturedXunitTheoryTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The method under test.</param> public CulturedXunitTheoryTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string culture) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { Culture = Guard.ArgumentNotNull(culture); Traits.Add("Culture", Culture); var cultureDisplay = $"[{Culture}]"; TestCaseDisplayName += cultureDisplay; UniqueID += cultureDisplay; }
/// <summary> /// Creates test cases for a skipped theory. By default, returns a single instance of <see cref="XunitTestCase"/> /// (which inherently discovers the skip reason via the fact attribute). /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <param name="skipReason">The skip reason that decorates <paramref name="theoryAttribute"/>.</param> /// <returns>The test cases</returns> protected virtual IEnumerable <IXunitTestCase> CreateTestCasesForSkip( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute, string skipReason) { // TODO: Skip reason should be passed down into the test case var testCase = new XunitTestCase( DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod ); return(new[] { testCase }); }
TestableTestMethodRunner( _ITestMethod testMethod, _IReflectionTypeInfo @class, _IReflectionMethodInfo method, IEnumerable <_ITestCase> testCases, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, RunSummary result, bool cancelInRunTestCaseAsync) : base(testMethod, @class, method, testCases, messageBus, aggregator, cancellationTokenSource) { TokenSource = cancellationTokenSource; this.result = result; this.cancelInRunTestCaseAsync = cancelInRunTestCaseAsync; }
protected override ValueTask <IReadOnlyCollection <IXunitTestCase> > CreateTestCasesForTheory( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute) { var cultures = GetCultures(theoryAttribute); var result = cultures.Select( culture => new CulturedXunitTheoryTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture ) ).CastOrToReadOnlyCollection(); return(new(result)); }
/// <summary> /// Initializes a new instance of the <see cref="TestMethodRunner{TTestCase}"/> class. /// </summary> /// <param name="testMethod">The test method under test.</param> /// <param name="class">The CLR class that contains the test method.</param> /// <param name="method">The CLR method that contains the tests to be run.</param> /// <param name="testCases">The test cases to be run.</param> /// <param name="messageBus">The message bus to report run status to.</param> /// <param name="aggregator">The exception aggregator used to run code and collect exceptions.</param> /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param> protected TestMethodRunner( _ITestMethod testMethod, _IReflectionTypeInfo @class, _IReflectionMethodInfo method, IEnumerable <TTestCase> testCases, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { this.testMethod = Guard.ArgumentNotNull(nameof(testMethod), testMethod); this.@class = Guard.ArgumentNotNull(nameof(@class), @class); this.method = Guard.ArgumentNotNull(nameof(method), method); this.testCases = Guard.ArgumentNotNull(nameof(testCases), testCases); this.messageBus = Guard.ArgumentNotNull(nameof(messageBus), messageBus); this.aggregator = Guard.ArgumentNotNull(nameof(aggregator), aggregator); this.cancellationTokenSource = Guard.ArgumentNotNull(nameof(cancellationTokenSource), cancellationTokenSource); }
/// <summary> /// Initializes a new instance of the <see cref="TestMethodRunnerContext{TTestCase}"/> class. /// </summary> public TestMethodRunnerContext( _ITestClass testClass, _ITestMethod testMethod, _IReflectionTypeInfo @class, _IReflectionMethodInfo method, IReadOnlyCollection <TTestCase> testCases, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) : base(messageBus, aggregator, cancellationTokenSource) { TestClass = Guard.ArgumentNotNull(testClass); TestMethod = Guard.ArgumentNotNull(testMethod); Class = Guard.ArgumentNotNull(@class); Method = Guard.ArgumentNotNull(method); TestCases = Guard.ArgumentNotNull(testCases); }
/// <summary> /// Initializes a new instance of the <see cref="CulturedXunitTheoryTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The method under test.</param> public CulturedXunitTheoryTestCase( _IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string culture) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { Culture = Guard.ArgumentNotNull(nameof(culture), culture); Traits.Add("Culture", Culture); var cultureDisplay = $"[{Culture}]"; DisplayName += cultureDisplay; UniqueID += cultureDisplay; }
protected override IEnumerable <IXunitTestCase> CreateTestCasesForTheory( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute) { var cultures = GetCultures(theoryAttribute); return(cultures.Select( culture => new CulturedXunitTheoryTestCase( DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture ) ).ToList()); }
public TestableXunitTestCase( _ITestMethod testMethod, object?[]?testMethodArguments = null, _IMessageSink?diagnosticMessageSink = null) : base( diagnosticMessageSink ?? SpyMessageSink.Create(), TestMethodDisplay.ClassAndMethod, TestMethodDisplayOptions.None, testMethod, testMethodArguments, null, null, null, null ) { }
/// <summary> /// Creates test cases for a single row of skipped data. By default, returns a single instance of <see cref="XunitSkippedDataRowTestCase"/> /// with the data row inside of it. /// </summary> /// <remarks>If this method is overridden, the implementation will have to override <see cref="TestMethodTestCase.SkipReason"/> otherwise /// the default behavior will look at the <see cref="TheoryAttribute"/> and the test case will not be skipped.</remarks> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <param name="dataRow">The row of data for this test case.</param> /// <param name="skipReason">The reason this test case is to be skipped</param> /// <returns>The test cases</returns> protected virtual IEnumerable <IXunitTestCase> CreateTestCasesForSkippedDataRow( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute, object?[] dataRow, string skipReason) { var testCase = new XunitSkippedDataRowTestCase( DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow , skipReason); return(new[] { testCase }); }
/// <summary> /// Creates test cases for a single row of data. By default, returns a single instance of <see cref="XunitTestCase"/> /// with the data row inside of it. /// </summary> /// <param name="discoveryOptions">The discovery options to be used.</param> /// <param name="testMethod">The test method the test cases belong to.</param> /// <param name="theoryAttribute">The theory attribute attached to the test method.</param> /// <param name="displayName">The optional display name for the test</param> /// <param name="traits">The traits associated with the test case.</param> /// <param name="dataRow">The row of data for this test case.</param> /// <returns>The test cases</returns> protected virtual ValueTask <IReadOnlyCollection <IXunitTestCase> > CreateTestCasesForDataRow( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute, string?displayName, Dictionary <string, List <string> >?traits, object?[] dataRow) { var testCase = new XunitPreEnumeratedTheoryTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow, traits: traits, displayName: displayName ); return(new(new[] { testCase })); }
public CulturedXunitTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, string culture, object?[]?testMethodArguments = null, Dictionary <string, List <string> >?traits = null, string?displayName = null) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments, null, traits, null, null, displayName) { Culture = Guard.ArgumentNotNull(culture); Traits.Add("Culture", Culture); var cultureDisplay = $"[{Culture}]"; TestCaseDisplayName += cultureDisplay; UniqueID += cultureDisplay; }
static (string displayName, Exception?initException, _IMethodInfo method, _ITypeInfo[]? methodGenericTypes) Initialize( string baseDisplayName, _ITestMethod testMethod, object?[]?testMethodArguments) { string? displayName = null; Exception?initException = null; _ITypeInfo[]? methodGenericTypes = null; var method = testMethod.Method; if (testMethodArguments != null) { if (method is _IReflectionMethodInfo reflectionMethod) { try { testMethodArguments = reflectionMethod.MethodInfo.ResolveMethodArguments(testMethodArguments); } catch (Exception ex) { initException = ex; testMethodArguments = null; displayName = $"{baseDisplayName}(???)"; } } } if (testMethodArguments != null && method.IsGenericMethodDefinition) { methodGenericTypes = method.ResolveGenericTypes(testMethodArguments); method = method.MakeGenericMethod(methodGenericTypes); } if (displayName == null) { displayName = method.GetDisplayNameWithArguments(baseDisplayName, testMethodArguments, methodGenericTypes); } return(displayName, initException, method, methodGenericTypes); }
protected override ValueTask <IReadOnlyCollection <IXunitTestCase> > CreateTestCasesForDataRow( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo theoryAttribute, string?displayName, Dictionary <string, List <string> >?traits, object?[] dataRow) { var cultures = GetCultures(theoryAttribute); var result = cultures.Select( culture => new CulturedXunitTestCase( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture, dataRow, traits, displayName) ).CastOrToReadOnlyCollection(); return(new(result)); }
/// <summary> /// Initializes a new instance of the <see cref="XunitSkippedDataRowTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink which receives <see cref="_DiagnosticMessage"/> messages.</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The arguments for the test method.</param> /// <param name="skipReason">The reason that this test case will be skipped.</param> /// <param name="traits">The optional traits list; if not provided, will be read from trait attributes.</param> /// <param name="uniqueID">The optional unique ID for the test case; if not provided, will be calculated.</param> public XunitSkippedDataRowTestCase( _IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, _ITestMethod testMethod, object?[] testMethodArguments, string skipReason, Dictionary <string, List <string> >?traits = null, string?uniqueID = null) : base( diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments, Guard.ArgumentNotNull(nameof(skipReason), skipReason), traits, timeout: null, uniqueID ) { }
public ValueTask <IReadOnlyCollection <IXunitTestCase> > Discover( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo factAttribute) { var ctorArgs = factAttribute.GetConstructorArguments().ToArray(); var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast <string[]>().Single(); if (cultures == null || cultures.Length == 0) { cultures = new[] { "en-US", "fr-FR" } } ; var methodDisplay = discoveryOptions.MethodDisplayOrDefault(); var methodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault(); var result = cultures .Select(culture => CreateTestCase(testMethod, culture, methodDisplay, methodDisplayOptions)) .CastOrToReadOnlyCollection(); return(new(result)); } CulturedXunitTestCase CreateTestCase( _ITestMethod testMethod, string culture, TestMethodDisplay methodDisplay, TestMethodDisplayOptions methodDisplayOptions) { return(new CulturedXunitTestCase( methodDisplay, methodDisplayOptions, testMethod, culture )); } }