public void PersonDirTest() { //act PersonDir prsn = new PersonDir(); Assert.IsNotNull(prsn.Plist, "Error"); }
public void FetchDataTest6() { //Arrange string data = "cfile.csv"; //Act PersonDir person = new PersonDir(); //Assert Assert.AreEqual(person.FetchData(data, true), 2); }
public void FetchDataTest5() { //Arrange string data = "smith, edward, Male, yellow, 5/20/2000"; //Act PersonDir person = new PersonDir(); //Assert Assert.AreEqual(person.FetchData(data, false), 2); }
static void Main(string[] args) { //user input and instructions Console.WriteLine("Please enter the folder path for csv files"); Console.WriteLine("Note that comma seperated file should be named cfile.csv"); Console.WriteLine("Pipe seperated file should be named pfile.csv"); Console.WriteLine("Space seperated file should be named sfile.csv"); Console.WriteLine(); Console.WriteLine("Input Example"); Console.WriteLine("c:\\users\\user\\desktop"); int cntr = 0; while (true) { string input = Console.ReadLine(); //if the files have been processed and user hasn't pressed exit if (cntr == 1 && input != "exit") { continue; } //if the files have been processed and user pressed exit if (cntr == 1 && input == "exit") { break; } //folder path check if (Directory.Exists(input) == false) { Console.WriteLine("Please enter a valid path"); continue; } List <string> files = new List <string> { input + "\\cfile.csv", input + "\\pfile.csv", input + "\\sfile.csv" }; //checking for at least one valid file name within provided folder bool contains = false; foreach (string file in files) { if (File.Exists(file)) { contains = true; break; } } if (contains == false) { Console.WriteLine("Please include at least one valid file in the specified folder"); continue; } Console.Clear(); PersonDir pdir = new PersonDir(); //processing each input file while updating the user foreach (string file in files) { if (File.Exists(file)) { int proc_code = pdir.FetchData(file, true); if (proc_code == 2) { Console.WriteLine("All records in file " + file + " were included!"); } else if (proc_code == 1) { Console.WriteLine("Some records in file " + file + " were included!"); } else { Console.WriteLine("No records in file " + file + " were included!"); } } } Console.WriteLine("------------------------------------------------------------------"); Console.WriteLine(); //sort orders List <string> sorders = new List <string> { "gendername", "birthdate", "lname" }; //sorting processed files in different sort orders and displaying on the console foreach (string sorder in sorders) { List <PersonInfo> pinfos = pdir.SortData(sorder); Console.WriteLine("Output ordered by " + sorder); Console.WriteLine(); Console.WriteLine("{0,-16} {1,-16} {2,-8} {3,-10} {4,-10} ", "LastName", "FirstName", "Gender", "FaveColor", "Birth"); foreach (PersonInfo pinfo in pinfos) { Console.WriteLine("{0,-16} {1,-16} {2,-8} {3,-10} {4,-10} ", pinfo.Lname, pinfo.Fname, pinfo.Gendr, pinfo.Color, pinfo.Dob.ToString("M/d/yyyy")); } Console.WriteLine("---------------------------------------------------------------"); Console.WriteLine(); } Console.WriteLine("Finished processing, enter 'exit' to close the program"); cntr++; } }
public void SortDataTest5() { //Arrange List <PersonInfo> pinfos = new List <PersonInfo>(); PersonInfo pinfo = new PersonInfo { Lname = "smith", Fname = "edward", Gendr = "male", Color = "yellow", Dob = DateTime.Parse("5/20/2000") }; pinfos.Add(pinfo); pinfo = new PersonInfo { Lname = "thomas", Fname = "edward", Gendr = "male", Color = "purple", Dob = DateTime.Parse("2/16/2001") }; pinfos.Add(pinfo); pinfo = new PersonInfo { Lname = "fox", Fname = "kelly", Gendr = "female", Color = "green", Dob = DateTime.Parse("1/18/1990") }; pinfos.Add(pinfo); pinfo = new PersonInfo { Lname = "fox", Fname = "sandy", Gendr = "female", Color = "brown", Dob = DateTime.Parse("8/05/1992") }; pinfos.Add(pinfo); pinfo = new PersonInfo { Lname = "laflin", Fname = "stephen", Gendr = "male", Color = "burgandy", Dob = DateTime.Parse("09/02/2000") }; pinfos.Add(pinfo); PersonDir pdir = new PersonDir { Plist = pinfos }; //Act List <PersonInfo> srtd_info = pdir.SortData("gender"); List <string> name = new List <string> { "foxkelly", "foxsandy", "smithedward", "thomasedward", "laflinstephen" }; bool match = true; for (int cntr = 0; cntr < name.Count; cntr++) { if (name[cntr] != srtd_info[cntr].Lname + srtd_info[cntr].Fname) { match = false; break; } } //Assert Assert.AreEqual(match, true); }