protected override object GenerateValue(Type type, string referenceName, LinkedList<object> buildChain)
{
string country = null;
var context = buildChain?.Last.Value;
if (context != null)
{
var expression = new Regex("Country");
var property = context.FindProperties(expression).FirstOrDefault();
if (property != null)
{
country = (string)property.GetValue(context, null);
}
}
if (country == null)
{
var person = TestData.NextPerson();
return person.TimeZone;
}
var people =
TestData.People.Where(x => x.TimeZone.IndexOf(country, StringComparison.OrdinalIgnoreCase) > -1)
.ToList();
var filteredIndex = Generator.NextValue(0, people.Count - 1);
var filteredPerson = people[filteredIndex];
return filteredPerson.TimeZone;
}