<PackageReference Include="NUnit" Version="3.0.0-alpha-2" />

CombiningStrategyAttribute

Marks a test to use a particular CombiningStrategy to join any parameter data provided. Since this is the default, the attribute is optional.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using NUnit.Framework.Internal.Builders; using System; using System.Collections; using System.Collections.Generic; using System.Reflection; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public abstract class CombiningStrategyAttribute : TestCaseBuilderAttribute, ITestBuilder, IApplyToTest { private NUnitTestCaseBuilder _builder = new NUnitTestCaseBuilder(); private IParameterDataProvider _dataProvider = new ParameterDataProvider(); private ICombiningStrategy _strategy; protected CombiningStrategyAttribute(ICombiningStrategy strategy) { _strategy = strategy; } protected CombiningStrategyAttribute(object strategy) : this((ICombiningStrategy)strategy) { } public IEnumerable<TestMethod> BuildFrom(MethodInfo method, Test suite) { ParameterInfo[] parameters = method.GetParameters(); List<TestMethod> list = new List<TestMethod>(); if (parameters.Length > 0) { IEnumerable[] array = new IEnumerable[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { array[i] = _dataProvider.GetDataFor(parameters[i]); } { foreach (ITestCaseData testCase in _strategy.GetTestCases(array)) { list.Add(_builder.BuildTestMethod(method, suite, (ParameterSet)testCase)); } return list; } } return list; } public void ApplyToTest(Test test) { string text = _strategy.GetType().Name; if (text.EndsWith("Strategy")) text = text.Substring(0, text.Length - 8); test.Properties.Set("_JOINTYPE", text); } } }