Skip to content

Instantly share code, notes, and snippets.

Given the address
| Street | Village | Province | Postal Code | Location |
| 110 Prairie Way | Elkhorn | Manitoba | P5A 0A4 | (42, 88) |
Given the address
| Street | Village | Province | Postal Code |
| 110 Prairie Way | Elkhorn | Manitoba | P5A 0A4 |
public class Address
{
[TableAliases("Street")]
public string Line1 { get; set; }
[TableAliases("Township", "Village", "Municipality")]
public string City { get; set; }
[TableAliases("Province")]
public string State { get; set; }
[Then(@"the address is")]
public void ValidateAddress(Table table)
{
table.CompareToInstance(_address);
}
[Then(@"the address is")]
public void ValidateAddress(Table table)
{
Assert.AreEqual(table.Rows[0]["Line 1"], _address.Line1);
Assert.AreEqual(table.Rows[0]["Line 2"], _address.Line2);
Assert.AreEqual(table.Rows[0]["City"], _address.City);
Assert.AreEqual(table.Rows[0]["State"], _address.State);
Assert.AreEqual(table.Rows[0]["Zipcode"], _address.Zipcode);
}
[Given(@"the following address")]
public void GivenTheFollowingAddress(Table table)
{
Address address = table.CreateInstance<Address>();
}
[Given(@"the following address")]
public void GivenTheFollowingAddress(Table table)
{
Address address = new Address();
address.Line1 = table.Rows[0]["Line 1"];
address.Line2 = table.Rows[0]["Line 2"];
address.City = table.Rows[0]["City"];
address.State = table.Rows[0]["State"];
address.Zipcode = table.Rows[0]["Zipcode"];
# A horizontal table
| Line 1 | City | State | Zipcode |
| 30 Rockefeller Plaza | New York | NY | 10112 |
| 311 South Wacker Dr | Chicago | IL | 60606 |
# A vertical table
| Field | Value |
| Line 1 | 30 Rockefeller Plaza |
| City | New York |
| State | NY |
| Zipcode | 10112 |
[StepArgumentTransformation(@"(\d+)(?:st|nd|rd|th)")]
public int GetIndex(int index)
{
return index - 1;
}
[When(@"I remove the (.*) product")]
public void RemoveProduct(int index)
{
_products.RemoveAt(index);