Skip to content

Instantly share code, notes, and snippets.

using NUnit.Framework;
[assembly: Parallelizable(ParallelScope.Fixtures)]
private readonly ScenarioContext _scenarioContext;
public AddressSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
private readonly ScenarioContext _scenarioContext
= ScenarioContext.Current;
[BeforeTestRun]
public static void RegisterValueMappings()
{
var geoLocationValueHandler = new GeoLocationValueHandler();
Service.Instance.RegisterValueRetriever(geoLocationValueHandler);
Service.Instance.RegisterValueComparer(geoLocationValueHandler);
}
Scenario: Build a customer
Given the customer
| Salutation | First Name | Last Name |
| Miss | Liz | Lemon |
And the address
| Line 1 | City | State | Zipcode |
| 30 Rockefeller Plaza | New York | NY | 10112 |
Scenario: Build a customer
Given the customer
| Name | Address |
| Miss Liz Lemon | 30 Rockefeller Plaza; New York; NY; 10112 |
public bool CanCompare(object actualValue)
{
return actualValue is GeoLocation;
}
public bool Compare(string expectedValue, object actualValue)
{
GeoLocation expectedLocation;
if (TryGetLocation(expectedValue, out expectedLocation))
public bool CanRetrieve(KeyValuePair<string, string> keyValuePair,
Type targetType, Type propertyType)
{
return propertyType == typeof(GeoLocation);
}
public object Retrieve(KeyValuePair<string, string> keyValuePair,
Type targetType, Type propertyType)
{
string coordinates = keyValuePair.Value;
public class Address
{
[TableAliases("Street")]
public string Line1 { get; set; }
[TableAliases("Township", "Village")]
public string City { get; set; }
[TableAliases("Province")]
public string State { get; set; }
Given the address
| Street | Village | Province | Postal Code | Location |
| 110 Prairie Way | Elkhorn | Manitoba | P5A 0A4 | (42, 88) |