public void writeGoodDataToEmptyFileSN() { string path = @"DBase\DBase.txt"; File.Delete(path);//makes sure file does not exist beforehand DateTime DOB = new DateTime(1993, 04, 24); AllEmployees.SeasonalEmployee SNEmp = new AllEmployees.SeasonalEmployee("Brandon", "Davies", 123456789, DOB, "Summer", 10); List<AllEmployees.Employee> empList = new List<AllEmployees.Employee>(); empList.Add(SNEmp); FileIO.WriteRecord(empList, path);//if true the data was correct and written to the file string rawEmployeeRec = File.ReadAllText(path); Assert.IsTrue(rawEmployeeRec == (SNEmp.ToString() + "\r\n")); }
public void readGoodData() { string path = @"DBase\DBase.txt"; File.Delete(path);//makes sure file does not exist beforehand string fileData = "CT|Brandon||933456793|1993-04-24|2000-12-12|2004-03-02|18.78|" + "\r\n" + "FT|Brandon|Davies|933456793|1993-04-24|2000-12-12|2004-03-02|18.78|" + "\r\n" + "PT|Brandon|Davies|933456793|1993-04-24|2000-12-12|2004-03-02|18.78|" + "\r\n" + "SN|Brandon|Davies|123456789|1993-04-24|Summer|10|"; StreamWriter sw = File.AppendText(path);//write data (Details Method) sw.WriteLine(fileData);//will append if file exists or create new if it does not already exist sw.Close(); List<AllEmployees.Employee> EmpRecords = new List<AllEmployees.Employee>(); List<AllEmployees.Employee> sampleRecords = new List<AllEmployees.Employee>(); EmpRecords = FileIO.ReadAllRecords(path); DateTime DOB = new DateTime(1993, 04, 24); DateTime DOH = new DateTime(2000, 12, 12); DateTime DOT = new DateTime(2004, 03, 02); AllEmployees.ContractEmployee CTEmp = new AllEmployees.ContractEmployee("", "Brandon", 933456793, DOB, DOH, DOT, 18.78); AllEmployees.FulltimeEmployee FTEmp = new AllEmployees.FulltimeEmployee("Davies", "Brandon", 933456793, DOB, DOH, DOT, 18.78); AllEmployees.ParttimeEmployee PTEmp = new AllEmployees.ParttimeEmployee("Davies", "Brandon", 933456793, DOB, DOH, DOT, 18.78); AllEmployees.SeasonalEmployee SNEmp = new AllEmployees.SeasonalEmployee("Davies", "Brandon", 123456789, DOB, "Summer", 10); sampleRecords.Add(CTEmp); sampleRecords.Add(FTEmp); sampleRecords.Add(PTEmp); sampleRecords.Add(SNEmp); Assert.IsTrue(((AllEmployees.ContractEmployee)EmpRecords[0]).ToString() == CTEmp.ToString()); Assert.IsTrue(((AllEmployees.FulltimeEmployee)EmpRecords[1]).ToString() == FTEmp.ToString()); Assert.IsTrue(((AllEmployees.ParttimeEmployee)EmpRecords[2]).ToString() == PTEmp.ToString()); Assert.IsTrue(((AllEmployees.SeasonalEmployee)EmpRecords[3]).ToString() == SNEmp.ToString()); }