public void CreateProperties() { var resFactory = new ResidentialFactory(); var transFactory = new TransportFactory(); var utilFactory = new UtilityFactory(); var genericFactory = new PropertyFactory(); var luckFactory = new LuckFactory(); try { var propertyDetails = _fileReader.ReadPropertyDetailsFromCSV(); // Add the properties to the board foreach (var propertyDetail in propertyDetails) { switch (propertyDetail.Type.ToLower()) { case "luck": Board.Access() .AddProperty(luckFactory.create(propertyDetail.Name, propertyDetail.IsPenalty, propertyDetail.Amount)); break; case "residential": Board.Access() .AddProperty(resFactory.create(propertyDetail.Name, propertyDetail.Price, propertyDetail.Rent, propertyDetail.HouseCost, propertyDetail.HouseColour)); break; case "transport": Board.Access().AddProperty(transFactory.create(propertyDetail.Name)); break; case "utility": Board.Access().AddProperty(utilFactory.create(propertyDetail.Name)); break; case "generic": Board.Access().AddProperty(genericFactory.Create(propertyDetail.Name)); break; } } Console.WriteLine("Properties have been setup"); } catch (Exception ex) { Console.WriteLine("Oops, something went wrong setting up the properties: {0}", ex.Message); } }
public void test_utility() { //create instance of factory UtilityFactory f = new UtilityFactory(); //create instance from factory Utility p = f.create("Utility"); //check that it is right type Type t = new Utility().GetType(); Assert.IsInstanceOfType(t, p); }