/// <summary> /// Create a sample person from example data. /// </summary> /// <param name="id">The id of the person.</param> /// <param name="name">The name, or "null" for a null value.</param> /// <param name="dateOfBirth">The date of birth.</param> /// <param name="context">The scenario context (or null if you do not wish to set the value into the context).</param> /// <param name="keyToSet">The key to set in the scenario context (or null if you do not wish to set the value into the context).</param> /// <returns>The example person created.</returns> internal static Person CreatePerson(string id, string name, string dateOfBirth, ScenarioContext?context = null, string?keyToSet = null) { var person = new Person { Id = id, Name = ValueUtilities.GetNullableString(name), DateOfBirth = ValueUtilities.GetNullableDateTimeOffset(dateOfBirth), }; if (context != null && keyToSet != null) { context.Set(person, keyToSet); } return(person); }
/// <summary> /// Create a sample people from example data. /// </summary> /// <param name="table">The table from which to create the people. This should have columns <c>Id</c>, <c>Name</c> (which is nullable) and <c>DateOfBirth</c>.</param> /// <param name="context">The scenario context (or null if you do not wish to set the value into the context).</param> /// <param name="keyToSet">The key to set in the scenario context (or null if you do not wish to set the value into the context).</param> /// <returns>The example person created.</returns> internal static IList <Person> CreatePeople(Table table, ScenarioContext?context = null, string?keyToSet = null) { var people = table.Rows.Select( row => new Person { Id = row["Id"], Name = ValueUtilities.GetNullableString(row["Name"]), DateOfBirth = ValueUtilities.GetNullableDateTimeOffset(row["DateOfBirth"]), }).ToList(); if (context != null && keyToSet != null) { context.Set(people, keyToSet); } return(people); }