Exemple #1
0
        /// <summary>
        /// \brief <b>Description</b>
        /// \details This function adds an employee to the collection given all the values
        /// of a valid Fulltime, Parttime, or Contract Employee
        /// </summary>
        /// <param name="type">the type of employee (Fulltime, Parttime, or Contract)</param>
        /// <param name="firstName"> - first name of the employee</param>
        /// <param name="lastName"> - last name of the employee</param>
        /// <param name="dob"> - Date of birth of the employee</param>
        /// <param name="sin"> - Social Insurance Number of the employee</param>
        /// <param name="startDate"> - Date of Hire of the employee</param>
        /// <param name="stopDate"> - Date of termination of the employee</param>
        /// <param name="payAmount"> - Annual salary of the employee</param>
        /// <returns>True if the employee was added successfully</returns>
        public bool addEmployee(EmployeeType type, string fName, string lName, DateTime dob, string sin,
                                DateTime startDate, DateTime?stopDate, double payAmount)
        {
            bool     retCode = false;
            Employee emp     = null;

            switch (type)
            {
            case EmployeeType.FT:
                if (retCode = FulltimeEmployee.validate(fName, lName, dob, sin, startDate, stopDate, payAmount))
                {
                    emp = new FulltimeEmployee(fName, lName, dob, sin, startDate, stopDate, payAmount);
                }
                break;

            case EmployeeType.PT:
                if (retCode = ParttimeEmployee.validate(fName, lName, dob, sin, startDate, stopDate, payAmount))
                {
                    emp = new ParttimeEmployee(fName, lName, dob, sin, startDate, stopDate, payAmount);
                }
                break;

            case EmployeeType.CT:
                if (stopDate != null)
                {
                    if (retCode = ContractEmployee.validate(lName, dob, sin, startDate, (DateTime)stopDate, payAmount))
                    {
                        emp = new ContractEmployee(lName, dob, sin, startDate, (DateTime)stopDate, payAmount);
                    }
                }
                break;

            default:
                break;
            }
            if (retCode)
            {
                if (EmployeeList.ContainsKey(emp.SIN))
                {
                    retCode = false;
                }
                else
                {
                    EmployeeList.Add(emp.SIN, emp);
                    Logging.Log("[Container.AddEmployee] Employee Added - " + emp.LastName + ", "
                                + emp.FirstName + " (" + emp.SIN + ") - VALID");
                }
            }
            return(retCode);
        }
        public void ValidateOverloadExceptionTestCase()
        {
            //Arrange
            bool     expected          = false;
            bool?    actual            = null;
            string   firstName         = "Nathan";
            string   lastName          = "Bray";
            DateTime dob               = DateTime.Parse("1993-09-15");
            string   sin               = "333333334";
            DateTime dateOfHire        = DateTime.Parse("2015-04-12");
            DateTime dateOfTermination = DateTime.Parse("2012-08-13");
            double   salary            = 54749.00;

            //Act
            actual = FulltimeEmployee.validate(firstName, lastName, dob, sin, dateOfHire, dateOfTermination, salary);
            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void ValidateNormalTestCase()
        {
            //Arrange
            bool             expected   = true;
            bool?            actual     = null;
            FulltimeEmployee ftEmployee = new FulltimeEmployee();

            ftEmployee.FirstName         = "Jody";
            ftEmployee.LastName          = "Markic";
            ftEmployee.DOB               = DateTime.Parse("1993-08-24");
            ftEmployee.SIN               = "123456782";
            ftEmployee.DateOfHire        = DateTime.Parse("2012-04-12");
            ftEmployee.DateOfTermination = DateTime.Parse("2015-06-04");
            ftEmployee.Salary            = 54750.00;
            //Act
            actual = FulltimeEmployee.validate(ftEmployee);
            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        /// <summary>
        /// \brief <b>Description</b>
        /// \details This function adds an employee to the collection
        /// </summary>
        /// <param name="emp">This is the employee that will be added</param>
        /// <returns>True if the employee was added successfully</returns>
        public bool addEmployee(Employee emp)
        {
            bool retCode = false;

            switch (getType(emp))
            {
            case EmployeeType.FT:
                retCode = FulltimeEmployee.validate((FulltimeEmployee)emp);
                break;

            case EmployeeType.PT:
                retCode = ParttimeEmployee.validate((ParttimeEmployee)emp);
                break;

            case EmployeeType.CT:
                retCode = ContractEmployee.validate((ContractEmployee)emp);
                break;

            case EmployeeType.SN:
                retCode = SeasonalEmployee.validate((SeasonalEmployee)emp);
                break;

            default:
                break;
            }

            if (retCode)
            {
                if (EmployeeList.ContainsKey(emp.SIN))
                {
                    retCode = false;
                }
                else
                {
                    EmployeeList.Add(emp.SIN, emp);
                    Logging.Log("[Container.AddEmployee] Employee Added - " + emp.LastName + ", "
                                + emp.FirstName + " (" + emp.SIN + ") - VALID");
                }
            }
            return(retCode);
        }