Esempio n. 1
0
 public void ConstructorWithAllParamTestInvalidDOHBeforeDOB()
 {
     DateTime DOB = new DateTime(2003, 12, 12);
     DateTime DOH = new DateTime(2001, 02, 27);
     DateTime DOT = new DateTime(2002, 05, 21);
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
 }
Esempio n. 2
0
        public ParttimeEmployee(ParttimeEmployee prev)
            : base(prev)
        {
            dateOfHire        = prev.GetDateOfHire();
            dateOfTermination = prev.GetDateOfTermination();
            hourlyRate        = prev.GetHourlyRate();

            SetType("SN");
        }
 /// <summary>
 /// Add a new employee type, given a set of information the method will decide which employee type is requested to be created and to provide the 
 /// information in creating that specific employee type 
 /// </summary>
 /// <param name="record">Contains a set of information regarding which employee type to create and what information it should contain</param>
 /// <returns></returns>
 public void Add(object record)
 {
     if (((string)record)[0] != ';')
     {
         try
         {
             string[] recordStr = ((string)record).Split('|');
             Employee newEmployee = null;
             switch (recordStr[0].ToUpper())
             {
                 case "FT":
                     newEmployee = new FulltimeEmployee(recordStr);
                     break;
                 case "PT":
                     newEmployee = new ParttimeEmployee(recordStr); //PARAM Needs to be changed, temp fix
                     break;
                 case "CT":
                     newEmployee = new ContractEmployee(recordStr); //PARAM Needs to be changed, temp fix
                     break;
                 case "SN":
                     newEmployee = new SeasonalEmployee(recordStr); //PARAM Needs to be changed, temp fix
                     break;
                 default:
                     break;
             }
             if (newEmployee != null)
             {
                 if (newEmployee.IsValid)
                 {
                     //Exist by sin
                     if (!employeeSinExist(newEmployee))
                     {
                         employees.Add(newEmployee);
                     }
                     else
                     {
                         Logging.LogString("Tried adding employee but the SIN/BN matched another record.");
                         throw new ArgumentException("That Sin Already Exists");
                     }
                 }
                 else
                 {
                     //Employee is not valid dont add Needs LOG
                 }
             }
         }
         catch (MissingMemberException mME)
         {
             //throw mME;
         }
         catch (ArgumentException aE)
         {
             throw aE;
         }
     }
 }
        public void AddNormalTest()
        {
            EmployeeContainer ec = new EmployeeContainer("test", "AddNormalTestLog");
            ParttimeEmployee pe = new ParttimeEmployee(
                new DateTime(1999, 12, 31),
                new DateTime(2000, 1, 1),
                10,
                "Testy",
                "Peoper",
                new DateTime(1950, 1, 1),
                "111222333"
            );

            Assert.AreEqual(ec.Add(pe), true);
        }
        public void AddExceptionTest()
        {
            EmployeeContainer ec = new EmployeeContainer("test", "AddExceptionTestLog");
            ParttimeEmployee pe = new ParttimeEmployee(
                new DateTime(1999, 12, 31),
                new DateTime(2000, 1, 1),
                10,
                "Testy",
                "Peoper",
                new DateTime(1900, 1, 1), //invalid date of birth
                "111222333"
            );

            Assert.AreEqual(ec.Add(pe), false);
        }
Esempio n. 6
0
        public void SetDateOfHireIntsTestInvalidDate()
        {
            ParttimeEmployee employee = new ParttimeEmployee();
            bool retVal = employee.SetDateOfHire(1993, 04, 31);
            Assert.IsFalse(retVal);

            DateTime date = new DateTime();
            int compReturn = DateTime.Compare(employee.GetDateOfHire(), date);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 7
0
 public void SetHourlyRateInvalidNegitive()
 {
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies");
     bool retVal = employee.SetHourlyRate(-18);
     Assert.IsFalse(retVal);
     Assert.AreEqual(employee.GetHourlyRate(), 0);
 }
        public void GetCopyAtNormalTest()
        {
            EmployeeContainer ec = new EmployeeContainer("test", "GetCopyAtNormalTestLog");
            ParttimeEmployee pe = new ParttimeEmployee(
                new DateTime(1999, 12, 31),
                new DateTime(2000, 1, 1),
                10,
                "Testy",
                "Peoper",
                new DateTime(1950, 1, 1),
                "111222333"
            );

            ec.Add(pe);
            Employee peCopy = ec.GetCopyAt(0);

            Assert.AreEqual(peCopy.Details(), pe.Details());
        }
Esempio n. 9
0
        public void SetDateOfTerminationDateTestInvalidDOTbeforeDOH()
        {
            DateTime DOB = new DateTime(1954, 08, 20);
            DateTime DOH = new DateTime(1994, 09, 03);
            DateTime DOT = new DateTime(2000, 03, 23);
            ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
            DateTime date = new DateTime(1992, 04, 23);
            bool retVal = employee.SetDateOfTermination(date);
            Assert.IsFalse(retVal);

            int compReturn = DateTime.Compare(employee.GetDateOfTermination(), DOT);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 10
0
        /**
        * \brief Give employee write and file to write to
        *
        * \details <b>Details</b>
        *
        * \employeeList - <b>List<AllEmployees.Employee></b> - The employees records
        * \param fileName - <b>String</b> - The file path and name of file storing the records
        *
        * \return  umOfRecordsSaved - <b>Int</b> - The number of employees that were sucessfully saved
        */
        public static int WriteRecord(List<AllEmployees.Employee> employeeList, String fileName)
        {
            int numOfRecordsSaved = 0;
            if (wasRead == true)
            {
                File.WriteAllText(fileName, String.Empty);
            }
            foreach (Employee emp in employeeList)
            {
                string identifier = emp.GetEmployeeType();
                string fileOutput = "";

                if (identifier == "CT")
                {
                    AllEmployees.ContractEmployee employeeData = new AllEmployees.ContractEmployee();
                    employeeData = (AllEmployees.ContractEmployee)emp;
                    if (employeeData.Validate() == true)
                    {
                        fileOutput = employeeData.ToString();//test sample of gow to format
                        StreamWriter sw = File.AppendText(fileName);//write data (Details Method)
                        sw.WriteLine(fileOutput);//will append if file exists or create new if it does not already exist
                        sw.Close();
                        Logging.Log("FileIO", "WriteAllRecords", "ContractEmployee written to file");
                        numOfRecordsSaved++;
                    }
                    else
                    {
                        Logging.Log("FileIO", "WriteAllRecords", "ContractEmployee was invalid and was not written to file");
                    }
                }
                else if (identifier == "FT")
                {
                    AllEmployees.FulltimeEmployee employeeData = new AllEmployees.FulltimeEmployee();
                    employeeData = (AllEmployees.FulltimeEmployee)emp;
                    if (employeeData.Validate() == true)
                    {
                        fileOutput = employeeData.ToString();//test sample of gow to format
                        StreamWriter sw = File.AppendText(fileName);//write data (Details Method)
                        sw.WriteLine(fileOutput);//will append if file exists or create new if it does not already exist
                        sw.Close();
                        Logging.Log("FileIO", "WriteAllRecords", "FulltimeEmployee written to file");
                        numOfRecordsSaved++;
                    }
                    else
                    {
                        Logging.Log("FileIO", "WriteAllRecords", "FullTimeEmployee was invalid and was not written to file");
                    }
                }
                else if (identifier == "PT")
                {
                    AllEmployees.ParttimeEmployee employeeData = new AllEmployees.ParttimeEmployee();
                    employeeData = (AllEmployees.ParttimeEmployee)emp;
                    if (employeeData.Validate() == true)
                    {
                        fileOutput = employeeData.ToString();//test sample of gow to format
                        StreamWriter sw = File.AppendText(fileName);//write data (Details Method)
                        sw.WriteLine(fileOutput);//will append if file exists or create new if it does not already exist
                        sw.Close();
                        Logging.Log("FileIO", "WriteAllRecords", "ParttimeEmployee written to file");
                        numOfRecordsSaved++;
                    }
                    else
                    {
                        Logging.Log("FileIO", "WriteAllRecords", "PartTimeEmployee was invalid and was not written to file");
                    }
                }
                else if (identifier == "SN")
                {
                    AllEmployees.SeasonalEmployee employeeData = new AllEmployees.SeasonalEmployee();
                    employeeData = (AllEmployees.SeasonalEmployee)emp;
                    if (employeeData.Validate() == true)
                    {
                        fileOutput = employeeData.ToString();//test sample of gow to format
                        StreamWriter sw = File.AppendText(fileName);//write data (Details Method)
                        sw.WriteLine(fileOutput);//will append if file exists or create new if it does not already exist
                        sw.Close();
                        Logging.Log("FileIO", "WriteAllRecords", "SeasonalEmployee written to file");
                        numOfRecordsSaved++;
                    }
                    else
                    {
                        Logging.Log("FileIO", "WriteAllRecords", "SeasonalEmployee was invalid and was not written to file");
                    }
                }
                else
                {
                    Logging.Log("FileIO", "WriteAllRecords", "invalid unknown employee type was not written to file: " + identifier);
                }
            }
            return numOfRecordsSaved;
        }
Esempio n. 11
0
 public void ConstructorWithAllParamTestValid3()
 {
     DateTime DOB = new DateTime(1830, 07, 29);
     DateTime DOH = new DateTime(2013, 05, 12);
     DateTime DOT = new DateTime();
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
 }
Esempio n. 12
0
 public void ConstructorWithAllParamTestInvalidDOTBoforeDOH()
 {
     DateTime DOB = new DateTime(1993, 11, 14);
     DateTime DOH = new DateTime(2012, 10, 19);
     DateTime DOT = new DateTime(2010, 07, 29);
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
 }
Esempio n. 13
0
 public void ConstructorWithAllParamTestValid1()
 {
     DateTime DOB = new DateTime(1993, 04, 24);
     DateTime DOH = new DateTime(2000, 12, 12);
     DateTime DOT = new DateTime();
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
 }
Esempio n. 14
0
 public void ConstructorWithAllParamTestValid2()
 {
     DateTime DOB = new DateTime(1954, 08, 20);
     DateTime DOH = new DateTime(1994, 09, 03);
     DateTime DOT = new DateTime(2014, 12, 23);
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Mc'Davies", 123456789, DOB, DOH, DOT, 18);
 }
Esempio n. 15
0
 public void ConstructorWithAllParamTestInvalidSIN()
 {
     DateTime DOB = new DateTime(1984, 02, 15);
     DateTime DOH = new DateTime(1986, 02, 15);
     DateTime DOT = new DateTime();
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 1234756789, DOB, DOH, DOT, 18);
 }
Esempio n. 16
0
 public void ToStringTestValid()
 {
     DateTime DOB = new DateTime(1954, 08, 20);
     DateTime DOH = new DateTime(1994, 09, 03);
     DateTime DOT = new DateTime(2014, 12, 23);
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
     String toString = employee.ToString();
     Assert.IsTrue(toString == "|PT|Brandon|Davies|123456789|1954-08-20|1994-09-03|2014-12-23|18|");
 }
Esempio n. 17
0
 public void SetHourlyRateValid()
 {
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies");
     bool retVal = employee.SetHourlyRate(18);
     Assert.IsTrue(retVal);
     Assert.AreEqual(employee.GetHourlyRate(), 18);
 }
Esempio n. 18
0
        public void SetDateOfHireStringTestInvalidDOHafterDOT()
        {
            DateTime DOB = new DateTime(1954, 08, 20);
            DateTime DOH = new DateTime(1994, 09, 03);
            DateTime DOT = new DateTime(2000, 03, 23);
            ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
            bool retVal = employee.SetDateOfHire("2001-12-24");
            Assert.IsFalse(retVal);

            int compReturn = DateTime.Compare(employee.GetDateOfHire(), DOH);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 19
0
 public void ConstructorWithNamesTestInvalidNumber()
 {
     ParttimeEmployee employee = new ParttimeEmployee("Brandon2", "Davies");
 }
Esempio n. 20
0
        public void SetDateOfHireStringTestInvalidFormat()
        {
            ParttimeEmployee employee = new ParttimeEmployee();
            bool retVal = employee.SetDateOfHire("19930424");
            Assert.IsFalse(retVal);

            DateTime date = new DateTime();
            int compReturn = DateTime.Compare(employee.GetDateOfHire(), date);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 21
0
 public void ConstructorWithNamesTestInvalidSpace()
 {
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Mc Davies");
 }
Esempio n. 22
0
        public void SetDateOfHireStringTestValidString()
        {
            ParttimeEmployee employee = new ParttimeEmployee();
            bool retVal = employee.SetDateOfHire("1993-04-24");
            Assert.IsTrue(retVal);

            DateTime date = new DateTime(1993, 04, 24);
            int compReturn = DateTime.Compare(employee.GetDateOfHire(), date);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 23
0
 public void ConstructorWithNamesTestValid3()
 {
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "LeRoy-Davies");
 }
Esempio n. 24
0
        /**
         * @fn  private bool ModifyParttimeEmployee(ModifyParttimeEmployee employee, string returnMessage)
         *
         * @brief   allows user to modify this employee using the command line.
         *
         * @param   ModifyParttimeEmployee    The employee to modify.
         * @param   returnMessage       message displayed to the user as the option to return from this method.
         *
         * @return  whether the user canceled.
         */
        private bool ModifyParttimeEmployee(ParttimeEmployee employee, string returnMessage)
        {
            bool done = false;
            bool isCanceled = false;
            //loop until user goes back
            do {
                Console.Clear();
                Console.WriteLine(employee.Details());
                Console.WriteLine("1.   Change First Name(A-Z, a-z, ', -)");
                Console.WriteLine("2.   Change Last Name(A-Z, a-z, ', -)");
                Console.WriteLine("3.   Change Date of birth(yyyy-mm-dd)");
                Console.WriteLine("4.   Change Social insurance number");
                Console.WriteLine("5.   Change Date of hire(yyyy-mm-dd)");
                Console.WriteLine("6.   Change Date of termination(yyyy-mm-dd)");
                Console.WriteLine("7.   Change Hourly Rate");
                Console.WriteLine("8.   Cancel");
                Console.WriteLine("9.   " + returnMessage);

                //get user input until valid
                bool valid;
                do {
                    valid = true;
                    string input = Console.ReadLine();
                    switch (input) {
                        case "1":
                            Console.Write("Enter a new first name:");
                            while (employee.SetFirstName(Console.ReadLine()) == false) {
                                Console.Write("Invalid name, Enter a new first name:");
                            }
                            break;
                        case "2":
                            Console.Write("Enter a new last name:");
                            while (employee.SetLastName(Console.ReadLine()) == false) {
                                Console.Write("Invalid name, Enter a new last name:");
                            }
                            break;
                        case "3":
                            bool dateOfBirthDone = false;
                            while (!dateOfBirthDone) {
                                Console.Write("Enter a new date of birth:");
                                try {
                                    while (employee.SetDateofBirth(DateTime.ParseExact(Console.ReadLine(), "yyyy-MM-dd", CultureInfo.InvariantCulture)) == false) {
                                        Console.Write("Invalid date, Enter a new date of birth:");
                                    }
                                    dateOfBirthDone = true;
                                }
                                catch (FormatException ex) {
                                    Console.WriteLine("Invalid date, Format: yyyy-mm-dd");
                                    dateOfBirthDone = false;
                                }
                            }
                            break;
                        case "4":
                            Console.Write("Enter a new social insurance number:");
                            while (employee.SetSocialInsuranceNumber(Console.ReadLine()) == false){
                                Console.Write("Invalid number, Enter a new social insurance number:");
                            }
                            break;
                        case "5":
                            bool dateOfHireDone = false;
                            while (!dateOfHireDone) {
                                Console.Write("Enter a new date of hire:");
                                try {
                                    while (employee.SetDateOfHire(DateTime.ParseExact(Console.ReadLine(), "yyyy-MM-dd", CultureInfo.InvariantCulture)) == false) {
                                        Console.Write("Invalid date, Enter a new date of hire:");
                                    }
                                    dateOfHireDone = true;
                                }
                                catch (FormatException ex) {
                                    Console.WriteLine("Invalid date, Format: yyyy-mm-dd");
                                    dateOfHireDone = false;
                                }
                            }
                            break;
                        case "6":
                            bool dateOfTerminationDone = false;
                            while (!dateOfTerminationDone)  {
                                Console.Write("Enter a new date of termination:");
                                try {
                                    while (employee.SetDateOfTermination(DateTime.ParseExact(Console.ReadLine(), "yyyy-MM-dd", CultureInfo.InvariantCulture)) == false) {
                                        Console.Write("Invalid date, Enter a new date of termination:");
                                    }
                                    dateOfTerminationDone = true;
                                }
                                catch (FormatException ex) {
                                    Console.WriteLine("Invalid date, Format: yyyy-mm-dd");
                                    dateOfTerminationDone = false;
                                }
                            }
                            break;
                        case "7":
                            bool hourlyRateDone = false;
                            while (!hourlyRateDone) {
                                Console.Write("Enter a new hourly rate:");
                                try  {
                                    while (employee.SetHourlyRate(decimal.Parse(Console.ReadLine())) == false) {
                                        Console.Write("Invalid rate, Enter a new hourly rate:");
                                    }

                                    hourlyRateDone = true;
                                }
                                catch (FormatException ex){
                                    Console.WriteLine("Hourly rate must be a number");
                                    hourlyRateDone = false;
                                }
                            }
                            break;
                        case "8":
                            done = true;//end
                            isCanceled = true;
                            break;
                        case "9":
                            done = true;//end
                            isCanceled = false;
                            break;
                        default:
                            Console.WriteLine("Invalid input, please enter number corrispoding to a menu option:");
                            valid = false;
                            break;
                    }
                } while (!valid);

            } while (!done);

            return isCanceled;
        }
Esempio n. 25
0
        public void RemoveEmployee_InvalidEmployeeNotInList_EmployeeIsNotRemoved()
        {
            // Instantiate a ParttimeEmployee object and a private object
            DateTime dateOfBirth = new DateTime(1987, 06, 22);
            DateTime dateOfHire = new DateTime(2013, 04, 12);
            DateTime dateOfTermination = new DateTime(2015, 01, 25);
            ParttimeEmployee PTEmployee = new ParttimeEmployee("Mark", "Smith", 872098933, dateOfBirth, dateOfHire, dateOfTermination, 30);
            var privateObject = new PrivateObject(employeeRepo);
            // Add an employee to the list before attempting to remove one
            employeeRepo.AddEmployeeToList(FTEmployee);

            // Execute the method that is being tested
            privateObject.Invoke("RemoveEmployee", PTEmployee);
            // Check if the expected result and actual result are the same
            List<Employee> employeeList = (List<Employee>)privateObject.GetField("listOfEmployees");
            Assert.AreEqual(1, employeeList.Count);
        }
Esempio n. 26
0
        /**
        * \brief given string from file, pars all data into list, return list valid employees
        *
        * \details <b>Details</b>
        *
        * \param fileText - <b>string</b> - The string of data containing an employees records
        *
        * \return  employeeRec - <b>List<AllEmployees.Employee></b> - The list of all the employee records in the strinng of data
        */
        private static List<AllEmployees.Employee> ParsRecord(String fileText)
        {
            List<AllEmployees.Employee> employeeRec = new List<AllEmployees.Employee>();
            //tostringbase string employeeString = firstName + "|" + lastName + "|" + SocialInsuranceNumber + "|" + DateOfBirth.Year + "-" + DateOfBirth.Month + "-" + DateOfBirth.Day + "|";
            char[] delimiterChars = { '|', '\n'};
            string[] words = fileText.Split(delimiterChars);
            int wordCounter = 0;
            while (wordCounter < words.Count() - 1)
            {
                if (words[wordCounter] == "CT")
                {
                    bool isValid = true;
                    if (words.Length > (wordCounter + 7))
                    {
                        //AllEmployees.ContractEmployee contractEmp = new AllEmployees.ContractEmployee(words[wordCounter], words[wordCounter+1], Convert.ToInt32(words[wordCounter+2]), words[wordCounter+3], words[wordCounter+4], words[wordCounter+5], Convert.ToDouble(words[wordCounter+6]));
                        try
                        {
                            AllEmployees.ContractEmployee contractEmp = new AllEmployees.ContractEmployee();
                            contractEmp.SetEmployeeType(words[wordCounter]);
                            wordCounter++;
                            contractEmp.SetLastName(words[wordCounter]);
                            wordCounter++;
                            wordCounter++;
                            contractEmp.SetSocialInsuranceNumber(Convert.ToInt32(words[wordCounter]));//only take an int
                            wordCounter++;
                            contractEmp.SetDateOfBirth(words[wordCounter]);
                            wordCounter++;

                            contractEmp.SetContractStartDate(words[wordCounter]);
                            wordCounter++;
                            isValid = contractEmp.SetContractStopDate(words[wordCounter]);
                            if (words[wordCounter] == "")
                            {
                                isValid = true;
                            }
                            wordCounter++;
                            contractEmp.SetFixedContractAmount(Convert.ToDouble(words[wordCounter]));
                            wordCounter++;

                            if (contractEmp.Validate() == true && isValid == true)
                            {
                                employeeRec.Add(contractEmp);
                                Logging.Log("FileIO", "ParsRecord", "contract employee added");
                                wordCounter++;
                            }
                            else
                            {
                                Logging.Log("FileIO", "ParsRecord", "invalid employee data for a contract employee");
                                while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                                {
                                    wordCounter++;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.Log("FileIO", "ParsRecord", "invalid employee data for a contract employee - Error Message: " + ex.Message);
                            while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                            {
                                wordCounter++;
                            }
                        }
                    }
                    else
                    {
                        Logging.Log("FileIO", "ParsRecord", "Not enough employee data for a contract employee");
                        break;
                    }
                }
                else if (words[wordCounter] == "FT")
                {
                    bool isValid = true;
                    if (words.Length > (wordCounter + 7))
                    {
                        AllEmployees.FulltimeEmployee fullTimeEmp = new AllEmployees.FulltimeEmployee();

                        try
                        {
                            fullTimeEmp.SetEmployeeType(words[wordCounter]);
                            wordCounter++;
                            fullTimeEmp.SetLastName(words[wordCounter]);
                            wordCounter++;
                            fullTimeEmp.SetFirstName(words[wordCounter]);
                            wordCounter++;
                            fullTimeEmp.SetSocialInsuranceNumber(Convert.ToInt32(words[wordCounter]));//only takes an int
                            wordCounter++;
                            fullTimeEmp.SetDateOfBirth(words[wordCounter]);
                            wordCounter++;

                            fullTimeEmp.SetDateOfHire(words[wordCounter]);
                            wordCounter++;
                            isValid = fullTimeEmp.SetDateOfTermination(words[wordCounter]);
                            if (words[wordCounter] == "")
                            {
                                isValid = true;
                            }
                            wordCounter++;
                            fullTimeEmp.SetSalary(Convert.ToDouble(words[wordCounter]));//only takes a float
                            wordCounter++;

                            if (fullTimeEmp.Validate() == true && isValid == true)
                            {
                                wordCounter++;
                                employeeRec.Add(fullTimeEmp);
                                Logging.Log("FileIO", "ParsRecord", "full time employee added");
                            }
                            else
                            {
                                Logging.Log("FileIO", "ParsRecord", "invalid employee data for a full time employee");
                                while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                                {
                                    wordCounter++;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.Log("FileIO", "ParsRecord", "invalid employee data for a full time employee - Error Message: " + ex.Message);
                            while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                            {
                                wordCounter++;
                            }
                        }
                    }

                    else
                    {
                        Logging.Log("FileIO", "ParsRecord", "Not enough employee data for a full time employee");
                        break;
                    }
                }
                else if (words[wordCounter] == "PT")
                {
                    if (words.Length > (wordCounter + 7))
                    {
                        bool isValid = true;
                        AllEmployees.ParttimeEmployee partTimeEmp = new AllEmployees.ParttimeEmployee();

                        try
                        {
                            partTimeEmp.SetEmployeeType(words[wordCounter]);
                            wordCounter++;
                            partTimeEmp.SetLastName(words[wordCounter]);
                            wordCounter++;
                            partTimeEmp.SetFirstName(words[wordCounter]);
                            wordCounter++;
                            partTimeEmp.SetSocialInsuranceNumber(Convert.ToInt32(words[wordCounter]));//only takes an int
                            wordCounter++;
                            partTimeEmp.SetDateOfBirth(words[wordCounter]);
                            wordCounter++;

                            partTimeEmp.SetDateOfHire(words[wordCounter]);
                            wordCounter++;
                            isValid = partTimeEmp.SetDateOfTermination(words[wordCounter]);
                            if (words[wordCounter] == "")
                            {
                                isValid = true;
                            }
                            wordCounter++;
                            partTimeEmp.SetHourlyRate(Convert.ToDouble(words[wordCounter]));//only takes a float
                            wordCounter++;

                            if (partTimeEmp.Validate() == true && isValid == true)
                            {
                                wordCounter++;
                                employeeRec.Add(partTimeEmp);
                                Logging.Log("FileIO", "ParsRecord", "part time employee added");
                            }
                            else
                            {
                                Logging.Log("FileIO", "ParsRecord", "invalid employee data for a part time employee");
                                while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                                {
                                    wordCounter++;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.Log("FileIO", "ParsRecord", "invalid employee data for a part time employee - Error Message: " + ex.Message);
                            while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                            {
                                wordCounter++;
                            }
                        }
                    }
                    else
                    {
                        Logging.Log("FileIO", "ParsRecord", "Not enough employee data for a part time employee");
                        break;
                    }
                }
                else if (words[wordCounter] == "SN")
                {
                    if (words.Length > (wordCounter + 6))
                    {
                        AllEmployees.SeasonalEmployee seasonalEmp = new AllEmployees.SeasonalEmployee();

                        try
                        {
                            seasonalEmp.SetEmployeeType(words[wordCounter]);
                            wordCounter++;
                            seasonalEmp.SetLastName(words[wordCounter]);
                            wordCounter++;
                            seasonalEmp.SetFirstName(words[wordCounter]);
                            wordCounter++;
                            seasonalEmp.SetSocialInsuranceNumber(Convert.ToInt32(words[wordCounter]));//only takes an int
                            wordCounter++;
                            Logging.Log("FileIO", "ParsRecord", "SN Birthday: " + words[wordCounter]);
                            seasonalEmp.SetDateOfBirth(words[wordCounter]);
                            wordCounter++;
                            Logging.Log("FileIO", "ParsRecord", "SN Season: " + words[wordCounter]);
                            seasonalEmp.SetSeason(words[wordCounter]);
                            wordCounter++;
                            Logging.Log("FileIO", "ParsRecord", "SN PiecePay: " + words[wordCounter]);
                            seasonalEmp.SetPiecePay(Convert.ToDouble(words[wordCounter]));//only takes a float
                            wordCounter++;

                            if (seasonalEmp.Validate() == true)
                            {
                                wordCounter++;
                                employeeRec.Add(seasonalEmp);
                                Logging.Log("FileIO", "ParsRecord", "seasonal employee added");
                            }
                            else
                            {
                                Logging.Log("FileIO", "ParsRecord", "invalid employee data for a seasonal employee");
                                while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                                {
                                    wordCounter++;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.Log("FileIO", "ParsRecord", "invalid employee data for a seasonal employee - Error Message: " + ex.Message);
                            while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                            {
                                wordCounter++;
                            }
                        }

                    }
                    else
                    {
                        Logging.Log("FileIO", "ParsRecord", "Not enough employee data for a seasonal employee");
                        break;
                    }
                }
                else
                {
                    //string className, string methodName, string eventDetails
                    Logging.Log("FileIO", "ParsRecord", "invalid employee type in file");
                    while (words[wordCounter] != "FT" && words[wordCounter] != "PT" && words[wordCounter] != "SN" && words[wordCounter] != "CT" && wordCounter < words.Count() - 1)
                    {
                        wordCounter++;
                    }
                }
            }
            return employeeRec;
        }
Esempio n. 27
0
 public void ConstructorWithAllParamTestInvalidNoDOH()
 {
     DateTime DOB = new DateTime(1993, 11, 14);
     DateTime DOH = new DateTime();
     DateTime DOT = new DateTime();
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 933456789, DOB, DOH, DOT, 180000);
 }
        public void ModifyNormalTest()
        {
            EmployeeContainer ec = new EmployeeContainer("test", "ModifyNormalTestLog");
            ParttimeEmployee pe = new ParttimeEmployee(
                new DateTime(1999, 12, 31),
                new DateTime(2000, 1, 1),
                10,
                "Testy",
                "Peoper",
                new DateTime(1950, 1, 1),
                "111222333"
            );

            ec.Add(pe);

            FulltimeEmployee fe = new FulltimeEmployee(
                new DateTime(2004, 3, 6),
                new DateTime(2010, 1, 17),
                1000,
                "Dirty",
                "Dan",
                new DateTime(1975, 5, 30),
                "333222111"
            );

            Assert.AreEqual(ec.Modify(0, fe), true);
        }
Esempio n. 29
0
        public void SetDateOfHireDateTestValidDate()
        {
            DateTime date = new DateTime(2012, 04, 23);
            ParttimeEmployee employee = new ParttimeEmployee();
            bool retVal = employee.SetDateOfHire(date);
            Assert.IsTrue(retVal);

            int compReturn = DateTime.Compare(employee.GetDateOfHire(), date);
            Assert.AreEqual(0, compReturn);
        }
Esempio n. 30
0
 public void DetailsTestValid()
 {
     DateTime DOB = new DateTime(1954, 08, 20);
     DateTime DOH = new DateTime(1994, 09, 03);
     DateTime DOT = new DateTime(2014, 12, 23);
     ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
     String details = employee.Details();
     Assert.IsTrue(details == "Employee Type: ParttimeEmployee\nName: Brandon Davies\nSocial Insurance Number: 123 456 789\nDate of Birth: 1954-08-20\nDate of Hire: 1994-09-03\nDate of Termionation2014-12-23\nHourly Rate: 18");
 }
Esempio n. 31
0
        public void SetDateOfTerminationStringTestValidString()
        {
            DateTime DOB = new DateTime(1954, 08, 20);
            DateTime DOH = new DateTime(1994, 09, 03);
            DateTime DOT = new DateTime(2000, 03, 23);
            ParttimeEmployee employee = new ParttimeEmployee("Brandon", "Davies", 123456789, DOB, DOH, DOT, 18);
            bool retVal = employee.SetDateOfTermination("1999-04-24");
            Assert.IsTrue(retVal);

            DateTime date = new DateTime(1999, 04, 24);
            int compReturn = DateTime.Compare(employee.GetDateOfTermination(), date);
            Assert.AreEqual(0, compReturn);
        }