I am looking for a way to have a step definition such as:
Given a collection of numbers 1,2,3,4
and map that to a step definition with either a int[], List, or IEnumerable
the regex (\d+(,\d+)*) matches, but means I need two parameters.
At present I have
[Given(@"a collection of numbers (\d+(,\d+)*)")]
public void givencollectionofnumbers(string p0, string p1)
{
//p0 is "1,2,3,4"
//p1 is ",4"
}
I have a simple workarouns that is
[Given(@"a collection of numbers (.*)")]
public void givencollectionofnumbers(string p0)
{
var numbers = p0.Split(',').Select(x => int.Parse(x));
}
but I would like to do this in a more elegant manner potentially changing the type of the numbers to doubles and also ensuring that the regex only maches lists of numbers.
I also would rather not use a table for this as it seems excessive for simple list of data
Can anyone help with this