public void ValidMethodOK() { //create an instance of the class ClsEmployee AnEmployee = new ClsEmployee(); //string variable to store any error message String Error = ""; DateTime hire_Date = DateTime.Now.Date; //invoke the method Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, salary, dep_ID, active); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void SalaryExtremeMax() { //create an instance of the class we want to create ClsEmployee AnEmployee = new ClsEmployee(); //string variable to store any error message String Error = ""; DateTime hire_Date = DateTime.Now.Date; //create some test data to pass to the method int salary = 4000000; //this should fail //invoke the method Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, Convert.ToString(salary), dep_ID, active); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void ManagerIDMaxLessOne() { //create an instance of the class we want to create ClsEmployee AnEmployee = new ClsEmployee(); //string variable to store any error message String Error = ""; DateTime hire_Date = DateTime.Now.Date; //create some test data to pass to the method int manager_ID = 199; //this should be ok //invoke the method Error = AnEmployee.Valid(emp_Name, job_Name, Convert.ToString(manager_ID), hire_Date, salary, dep_ID, active); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void EmployeeNameMinLessOne() { //create an instance of the class we want to create ClsEmployee AnEmployee = new ClsEmployee(); //string variable to store any error message String Error = ""; DateTime hire_Date = DateTime.Now.Date; //create some test data to pass to the method string emp_Name = ""; //this should trigger an error //invoke the method Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, salary, dep_ID, active); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
protected void btnOK_Click(object sender, EventArgs e) { ClsEmployee AnEmployee = new ClsEmployee(); string emp_Name = txtemp_Name.Text; string job_Name = txtjob_Name.Text; string dep_ID = txtdep_ID.Text; string hire_Date = txthire_Date.Text; string manager_ID = txtmanager_ID.Text; string salary = txtsalary.Text; string check = chkActive.Text; string Error = ""; Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, Convert.ToDateTime(hire_Date), salary, dep_ID, chkActive.Checked); if (Error == "") { AnEmployee.Emp_ID = emp_ID; AnEmployee.Emp_Name = emp_Name; AnEmployee.Job_Name = job_Name; AnEmployee.Manager_ID = Convert.ToInt32(manager_ID); AnEmployee.Hire_Date = Convert.ToDateTime(hire_Date); AnEmployee.Salary = Convert.ToInt32(salary); AnEmployee.Dep_ID = Convert.ToInt32(dep_ID); AnEmployee.Active = chkActive.Checked; clsEmployeeCollection EmployeeList = new clsEmployeeCollection(); if (Convert.ToInt32(emp_ID) == -1) { EmployeeList.ThisEmployee = AnEmployee; EmployeeList.Add(); } else { EmployeeList.ThisEmployee.Find(Convert.ToInt32(emp_ID)); EmployeeList.ThisEmployee = AnEmployee; EmployeeList.Update(); } Response.Redirect("DefaultEmployee.aspx"); } else { lblError.Text = Error; } }