Your problem is supported really nicely by the specflow step bindings, if you use a StepArgumentTransformation
. This is why I love specflow.
[When(@"you add the sum of (.*)")]
public void WhenYouAddTheSumOf(int[] p1)
{
ScenarioContext.Current.Pending();
}
[StepArgumentTransformation(@"(\d+(?:,\d+)*)")]
public int[] IntArray(string intCsv)
{
return intCsv.Split(',').Select(int.Parse).ToArray();
}
The StepArgumentTransformation here will allow you to take any comma separated list of ints in any step definition from now on, and accept it as an Array parameter.
It's worth learning a few regex bits if you want to play with StepArgumentTransformations, to make them nice and specific. Note I could have used (\d+(?:,\d+)*)
instead of .*
in the When binding too.