To answer the headline question: SpecFlow parses the regular expressions in the Given
spec, so you can do what you need if you're good with regexes. For 2 integer parameters, this would work:
[Given(@"the numbers are (\d+),(\d+)")]
public void GivenTheNumbersAre(int number1, int number2)
However, you have to define a parameter for each capture group. The easiest regex I know for a comma delimited list of integers, with no trailing comma, gets me to:
[Given(@"a list of numbers such as ((\d+,)+(\d+))")]
public void GivenAListOfNumbersSuchAs(string commaDelimitedIntegers, string most, string last)
{
and throw away the redundant last two parameters and just parse the first parameter:
var numbers = commaDelimitedIntegers
.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse).ToArray();
The only advantage this has over just using .+
for your regex is that intellisense in the feature file can tell you if your parameters don't match the regex.
If you're on the regex learning curve, you can check what you've got with console output:
var console = _scenarioContext.ScenarioContainer.Resolve<ISpecFlowOutputHelper>();
console.WriteLine(commaDelimitedIntegers);
console.WriteLine(most);
console.WriteLine(last.ToString());