public void TestEmployeeInsert()
        {
            Employee testEmployee = new Employee(Employee.GenerateNextEid(), "UnitTestEmployee", "UnitTestLname", "", "", 0);
            Assert.True(testEmployee.Insert());

            testEmployee.Delete();
        }
Beispiel #2
0
        public void TestSearchEmployeesWithValidQueryWithCloseFname()
        {
            int eid1 = Employee.GenerateNextEid();
            Employee e1 = new Employee(eid1, "SearchFname1", "SearchLname1", "", "", 1);
            e1.Insert();

            int eid2 = Employee.GenerateNextEid();
            Employee e2 = new Employee(eid2, "SearchFname2", "SearchLname2", "", "", 1);
            e2.Insert();

            List<string> db = new List<string>();
            db.Add("fname");

            List<string> s = new List<string>();
            s.Add("Search");

            Search search = new Search("Employee");
            search.UseInputs(db, s);

            List<Employee> e = Search.SearchEmployees(search.GetBuiltQuery());
            Assert.True(e.Count >= 2);

            e1.Delete();
            e2.Delete();
        }
 public void TestGetSetEid()
 {
     Employee e = new Employee(1);
     Assert.True(e.Eid == 1);
     e.Eid = 2;
     Assert.True(e.Eid == 2);
 }
        public void TestGetEmployees()
        {
            Employee testEmployee = new Employee(Employee.GenerateNextEid(), "UnitTestEmployee", "UnitTestLname", "", "", 0);
            testEmployee.Insert();

            List<Employee> employees = Employee.GetEmployees();
            Assert.IsNotEmpty(employees);

            testEmployee.Delete();
        }
        public void TestEmployeeUpdate()
        {
            Employee testEmployee = new Employee(Employee.GenerateNextEid(), "UnitTestEmployee", "UnitTestLname", "", "", 0);
            testEmployee.Insert();

            testEmployee.Fname = "ChangedName";
            Assert.True(testEmployee.Update());

            testEmployee.Delete();
        }
Beispiel #6
0
 /* Returns a list of employees based on query built from entries in UI
 */
 public static List<Employee> SearchEmployees(string queryBuilt)
 {
     List<Employee> getEmployees = new List<Employee>();
     try
     {
         List<object[]> employeeList = Database.Select(queryBuilt);
         if(employeeList != null)
         foreach (object[] row in employeeList)
         {
             Employee newEmployee = new Employee(Convert.ToInt32(row[0]), row[1].ToString(), row[2].ToString(),
                                         row[3].ToString(), row[4].ToString(), Convert.ToInt32(row[5]));
             getEmployees.Add(newEmployee);
         }
     }
     catch (Exception)
     {
         System.Windows.MessageBox.Show("Error getting data from database and/or converting");
     }
     return getEmployees;
 }
Beispiel #7
0
        public void TestSearchEmployeeWithMultipleExactFields()
        {
            int eid1 = Employee.GenerateNextEid();
            Employee e1 = new Employee(eid1, "SearchFname1", "SearchLname1", "Spec1", "Doctor", 100000);
            e1.Insert();

            int eid2 = Employee.GenerateNextEid();
            Employee e2 = new Employee(eid2, "SearchFname2", "SearchLname2", "Spec2", "Nurse", 120000);
            e2.Insert();

            List<string> db = new List<string>();
            db.Add("fname");
            db.Add("lname");
            db.Add("specialty");

            List<string> s = new List<string>();
            s.Add("SearchFname1");
            s.Add("SearchLname1");
            s.Add("Spec1");

            Search search = new Search("Employee");
            search.UseInputs(db, s);

            List<Employee> e = Search.SearchEmployees(search.GetBuiltQuery());
            Assert.True(e[0].Eid == eid1);

            e1.Delete();
            e2.Delete();
        }
Beispiel #8
0
        public void TestSearchEmployeesWithValidQueryWithOtherSpecialty()
        {
            int eid1 = Employee.GenerateNextEid();
            Employee e1 = new Employee(eid1, "SearchFname1", "SearchLname1", "Spec1", "Doctor", 100000);
            e1.Insert();

            int eid2 = Employee.GenerateNextEid();
            Employee e2 = new Employee(eid2, "SearchFname2", "SearchLname2", "Spec2", "Nurse", 120000);
            e2.Insert();

            List<string> db = new List<string>();
            db.Add("specialty");

            List<string> s = new List<string>();
            s.Add("Spec");

            Search search = new Search("Employee");
            search.UseInputs(db, s);

            List<Employee> e = Search.SearchEmployees(search.GetBuiltQuery());
            Assert.True(e.Count >= 2);

            e1.Delete();
            e2.Delete();
        }
Beispiel #9
0
        public void TestSearchEmployeesWithValidQueryWithExactType()
        {
            int eid1 = Employee.GenerateNextEid();
            Employee e1 = new Employee(eid1, "SearchFname1", "SearchLname1", "", "Type1", 100000);
            e1.Insert();

            int eid2 = Employee.GenerateNextEid();
            Employee e2 = new Employee(eid2, "SearchFname2", "SearchLname2", "", "Type2", 120000);
            e2.Insert();

            List<string> db = new List<string>();
            db.Add("employee_type");

            List<string> s = new List<string>();
            s.Add("Type1");

            Search search = new Search("Employee");
            search.UseInputs(db, s);

            List<Employee> e = Search.SearchEmployees(search.GetBuiltQuery());
            //Assert.True(e[0].Eid == eid1);

            e1.Delete();
            e2.Delete();
        }
Beispiel #10
0
 public void TestGetSetSpecialty()
 {
     Employee e = new Employee();
     e.Specialty = "Test";
     Assert.True(e.Specialty == "Test");
 }
Beispiel #11
0
 public void TestGetSetLname()
 {
     Employee e = new Employee();
     e.Lname = "Test";
     Assert.True(e.Lname == "Test");
 }
Beispiel #12
0
 public void TestGetSetType()
 {
     Employee e = new Employee();
     e.Employee_type = "Test";
     Assert.True(e.Employee_type == "Test");
 }
Beispiel #13
0
 public void TestGetSetSupervisor()
 {
     Employee e = new Employee();
     e.Supervisor_id = 1;
     Assert.True(e.Supervisor_id == 1);
 }
 public EmployeeInformation(Employee Employee)
 {
     InitializeComponent();
     _isNewEmployee = false;  //A new employee will not have an employee id to reference
     employee = Employee;
 }
 //Required for databinding -- END
 public EmployeeInformation()
 {
     InitializeComponent();
     employee = new Employee();
     generatedEID.Content = Employee.GenerateNextEid(); //Show the next EID when page loads
 }
Beispiel #16
0
 //Send in empty string if no search
 public static List<Employee> GetEmployees()
 {
     List<object[]> employeeList = Database.Select("Select * FROM Employee");
     List<Employee> getEmployees = new List<Employee>();
     if (employeeList != null)
     foreach (object[] row in employeeList)
     {
         Employee newEmployee = new Employee(Convert.ToInt32(row[0]), row[1].ToString(), row[2].ToString(),
                                     row[3].ToString(), row[4].ToString(), Convert.ToInt32(row[5]));
         getEmployees.Add(newEmployee);
     }
     return getEmployees;
 }