public void TestCSVFileLoad() { int EXPECTED_LINES = 31; string filePath = ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"); InMemoryCSVFile csvFile = InMemoryCSVFile.ReadCSVFile(filePath, true); Assert.IsTrue(csvFile.LineCount == EXPECTED_LINES); Assert.IsTrue(csvFile.HeaderRow.Length == 9); Assert.IsTrue(csvFile.HeaderRow[4] == "Team"); Assert.IsTrue(csvFile[1][4] == "Los Angeles Angels"); }
/// <summary> /// Loads all venues from file. /// </summary> /// <param name="filePath">string</param> /// <param name="hasHeaderRow">If set to <c>true</c> has header row.</param> private static void LoadVenuesFromFile(string filePath, bool hasHeaderRow = false) { Dictionary <string, Venue> ret = new Dictionary <string, Venue>(); InMemoryCSVFile venueCSV = InMemoryCSVFile.ReadCSVFile(filePath); for (int i = hasHeaderRow ? 1 : 0; i < venueCSV.LineCount; i++) { string id = venueCSV[i][4];//Team name is id int capacity = Convert.ToInt32(venueCSV[i][1]); string name = venueCSV[i][0]; string[] location = venueCSV[i][2].Split('|'); Venue theVenue = new Venue(id, capacity, name, $"{location[0]}, {location[1]}"); ret.Add(id, theVenue); } venues = ret; }