Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joebuschmann/97314cf578cefff7ac01 to your computer and use it in GitHub Desktop.

Select an option

Save joebuschmann/97314cf578cefff7ac01 to your computer and use it in GitHub Desktop.
When using numeric identifiers in Gherkin - code this
[Given(@"I have the following products")]
public void GivenIHaveTheFollowingProducts(Table table)
{
_productIdLookup = new Dictionary<string, int>();
foreach (var row in table.Rows)
_productIdLookup.Add(row["Name"], row.GetInt32("Id"));
}
[When(@"I select the (.*)")]
public void WhenISelectThe(string productName)
{
if (!_productIdLookup.ContainsKey(productName))
Assert.Fail("The product {0} does not exist in the look up dictionary.", productName);
_selectedProductId = _productIdLookup[productName];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment