/// <summary> /// Applies a random selection from the passed list to the provided Property Name. /// </summary> /// <param name="propertyName">The Property to apply the randomly selected List Item to.</param> /// <param name="list"> /// The IEnumerable<![CDATA[<Object>]]> to randomly choose a value from. /// </param> /// <returns>This instance of the Hydrator for type T.</returns> public Hydrator <T> FromList <TProperty>(Expression <Func <T, TProperty> > expression, IEnumerable <TProperty> list) { IGenerator <TProperty> gen = new FromListGetSingleGenerator <TProperty>(list); SetPropertyMap(expression, gen); return(this); }
public void ListGeneratorTest() { IList <string> testlist = new List <string>(); testlist.Add("hey"); testlist.Add("yay"); testlist.Add("nay"); IGenerator <string> listgen = new FromListGetSingleGenerator <string>(testlist); var checkme = (string)listgen.Generate(); Assert.IsNotNull(checkme); Assert.IsTrue(testlist.Contains(checkme)); }
/// <summary> /// Inserting data to Customer and Traffic tables /// </summary> /// <param name="pointsCount">How many point there will be</param> /// <param name="customersCount">How many costumers there will be ( will have 5 traffic per customer ) </param> private static void InsertDataIntoCustomerAndTrafficTables(int pointsCount, int customersCount) { ITrafficService trafficService = ServicesFactory.CreateTrafficServcie(); ICustomerService customerService = ServicesFactory.CreateCustomerService(); List <string> genders = new List <string>() { "M", "F", "?" }; List <string> bNumbers = new List <string>() { "tbaslacte", "ebanab", "HTML:internet/000", "blsl" }; List <string> directions = new List <string>() { "<-", "->" }; List <Coordinates> coorList = new List <Coordinates>(); for (int p = 0; p < pointsCount; p++) { coorList.Add(new Coordinates(new DecimalGenerator(48.1395m, 48.1693m).Generate(), new DecimalGenerator(17.0586m, 17.1730m).Generate())); } for (int c = 0; c < customersCount; c++) { Console.WriteLine("------------------------------------------------------"); string aNumber = new PhoneNumberGenerator().Generate(); var customer = new Customer() { Age = new IntegerGenerator(0, 100).Generate(), Gender = new FromListGetSingleGenerator <string>(genders).Generate(), Number = aNumber }; Console.WriteLine("Trying to add customer " + customer); customerService.InsertNewCostumer(customer); Console.WriteLine("Customer added successfuly"); for (int t = 0; t < 5; t++) { var coord = new FromListGetSingleGenerator <Coordinates>(coorList).Generate(); var trafic = new Traffic() { ANumber = aNumber, BNumber = new FromListGetSingleGenerator <string>(bNumbers).Generate(), Direction = new FromListGetSingleGenerator <string>(directions).Generate(), StartDateTime = new DateTimeGenerator(DateTime.Now.AddHours(-6), DateTime.Now.AddHours(6)).Generate(), CellLat = coord.Lat, CellLong = coord.Long }; Console.WriteLine("Trying to add traffic " + trafic); trafficService.InsertNewTraffic(trafic); Console.WriteLine("Traffic added successfuly"); } Console.WriteLine("------------------------------------------------------"); } Console.WriteLine("Operation successfuly"); }
public void ListGeneratorTest() { IList<string> testlist = new List<string>(); testlist.Add("hey"); testlist.Add("yay"); testlist.Add("nay"); IGenerator<string> listgen = new FromListGetSingleGenerator<string>(testlist); var checkme = (string) listgen.Generate(); Assert.IsNotNull(checkme); Assert.IsTrue(testlist.Contains(checkme)); }