private void MainForm_Load(object sender, EventArgs e) { courseCsv = CourseCSV.Initialize(); studCsv = StudentCSV.Initialize(); Task t = studCsv.LoadDataAsync(); t.Wait(); }
public void CourseCsvTestInitialize() { courseData.Clear(); var tmpPath = Path.Combine(Environment.CurrentDirectory, "Course.csv"); if (File.Exists(tmpPath)) { File.Delete(tmpPath); } File.Copy(courseTestFile, tmpPath); courseCsv = CourseCSV.Initialize(); Assert.IsNotNull(courseCsv, "Failed: Initialize CourseCSV object returns null!"); CSVAccess acc = new CSVAccess(); TextFieldParser parser = acc.GetCSVParser(courseTestFile); // skip over header line. parser.ReadLine(); while (!parser.EndOfData) { string[] v = new string[2]; string[] fields = parser.ReadFields(); v[0] = fields[1]; v[1] = fields[2]; try { if (!courseData.ContainsKey(fields[0])) { courseData.Add(fields[0], v); } } catch (Exception ex) { throw new Exception("Initializing unit test got exception: " + ex.Message); } } parser.Dispose(); }