<PackageReference Include="NUnit" Version="4.3.1" />

CombiningStrategyAttribute

Marks a test as using a particular CombiningStrategy to join any supplied parameter data. Since this is the default, the attribute is optional.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using NUnit.Framework.Internal.Builders; using NUnit.Framework.Internal.Extensions; using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace NUnit.Framework { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public abstract class CombiningStrategyAttribute : NUnitAttribute, ITestBuilder, IApplyToTest { private readonly NUnitTestCaseBuilder _builder = new NUnitTestCaseBuilder(); private readonly ICombiningStrategy _strategy; private readonly IParameterDataProvider _dataProvider; protected CombiningStrategyAttribute(ICombiningStrategy strategy, IParameterDataProvider provider) { _strategy = strategy; _dataProvider = provider; } protected CombiningStrategyAttribute(object strategy, object provider) : this((ICombiningStrategy)strategy, (IParameterDataProvider)provider) { } public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, [System.Runtime.CompilerServices.Nullable(2)] Test suite) { List<TestMethod> list = new List<TestMethod>(); IParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != 0) { int num = parameters.LastParameterAcceptsCancellationToken() ? (parameters.Length - 1) : parameters.Length; IEnumerable[] array = new IEnumerable[num]; try { for (int i = 0; i < num; i++) { array[i] = _dataProvider.GetDataFor(parameters[i]); } } catch (InvalidDataSourceException ex) { TestCaseParameters testCaseParameters = new TestCaseParameters(); testCaseParameters.RunState = RunState.NotRunnable; testCaseParameters.Properties.Set("_SKIPREASON", ex.Message); list.Add(_builder.BuildTestMethod(method, suite, testCaseParameters)); return list; } { foreach (ITestCaseData testCase in _strategy.GetTestCases(array)) { list.Add(_builder.BuildTestMethod(method, suite, (TestCaseParameters)testCase)); } return list; } } return list; } public void ApplyToTest(Test test) { string text = _strategy.GetType().Name; if (text.EndsWith("Strategy", StringComparison.Ordinal)) text = text.Substring(0, text.Length - 8); test.Properties.Set("_JOINTYPE", text); } } }