public void CmdLineApp_AddRecord()
 {
     DataManager dataMngr = new DataManager();
     dataMngr.ClearList();
     dataMngr.AddRecord("Last ", " First", "f", "Blue", "04/13/1971");
     string testString = dataMngr.PersonnelList[0].ToString();
     Assert.AreEqual(testString, "Last; First; Female; Blue; 04/13/1971");
 }
        public void CmdLineApp_GetData_Space()
        {
            List<Person> personnelList = GetInitialList();

            DataManager dataMngr = new DataManager();

            try
            {
                dataMngr.ClearList();
                string pathName = ConfigurationManager.AppSettings["testDataPath"];
                dataMngr.GetData(pathName, "Space.txt");
            }
            catch
            {
                Assert.Fail(" Exception");
            }

            CollectionAssert.AreEqual(dataMngr.PersonnelList, personnelList, " Mismatch");
        }
        public void CmdLineApp_SortData_ByBirthDate()
        {
            List<Person> personnelList = new List<Person>();
            personnelList.Add(new Person("Jones", "Tom", Gender.Male, "Blue", new DateTime(1967, 4, 13)));
            personnelList.Add(new Person("Walker", "Harry", Gender.Male, "Red", new DateTime(1971, 4, 13)));
            personnelList.Add(new Person("Johnson", "Mary", Gender.Female, "Green", new DateTime(1971, 4, 26)));
            personnelList.Add(new Person("Smith", "Dick", Gender.Male, "Black", new DateTime(1971, 12, 19)));
            personnelList.Add(new Person("King", "Amy", Gender.Female, "Yellow", new DateTime(1982, 2, 9)));
            personnelList.Add(new Person("MacDonald", "Jennifer", Gender.Female, "Brown", new DateTime(1986, 8, 14)));

            DataManager dataMngr = new DataManager();

            try
            {
                dataMngr.ClearList();
                string pathName = ConfigurationManager.AppSettings["testDataPath"];
                dataMngr.GetData(pathName, "Space.txt");
                dataMngr.SortData(DataManager.SortMethod.BirthDate);
            }
            catch
            {
                Assert.Fail(" Exception");
            }

            CollectionAssert.AreEqual(dataMngr.PersonnelList, personnelList, " Mismatch");
        }
        static void Main(string[] args)
        {
            DataManager dataMngr = new DataManager();

            Console.Write("Enter File Name:  ");
            string fileName = Console.ReadLine();

            char ch;
            bool validChar = true;
            if (dataMngr.GetData(null, fileName))
            {
                Console.Write("\nEnter Sort Method:\n  G - By Gender\n  B - By Birth Date\n  L - By Last Name\n");
                int asciiCode;

                do
                {
                    asciiCode = Console.Read();

                    if (asciiCode > 31)	// To handle LF and CR
                    {
                        switch (Convert.ToChar(asciiCode))
                        {
                            case 'g':
                            case 'G':
                                dataMngr.SortData(DataManager.SortMethod.Gender);
                                break;
                            case 'b':
                            case 'B':
                                dataMngr.SortData(DataManager.SortMethod.BirthDate);
                                break;
                            case 'l':
                            case 'L':
                                dataMngr.SortData(DataManager.SortMethod.LastName);
                                break;
                            case 'e':
                            case 'E':
                                break;
                            default:
                                Console.Write("Invalid character entered\n");
                                validChar = false;
                                break;
                        }

                        if (validChar)
                        {
                            Console.Write("\n");
                            foreach (Person person in dataMngr.PersonnelList)
                            {
                                Console.Write(person.ToString() + "\n");
                            }
                        }
                        else
                            validChar = true;

                        Console.Write("\nEnter Sort Method or E to exit:  ");
                    }
                } while ((Convert.ToChar(asciiCode) != 'e') && (Convert.ToChar(asciiCode) != 'E'));
            }
            else
            {
                Console.Write(dataMngr.Error + "\n");
                Console.Write("\nPress Enter key to exit");
                ch = Convert.ToChar(Console.Read());
            }
        }