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

            testEmployee.Delete();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 3
0
 public void TestGetSetEid()
 {
     Employee e = new Employee(1);
     Assert.True(e.Eid == 1);
     e.Eid = 2;
     Assert.True(e.Eid == 2);
 }
Ejemplo n.º 4
0
        public void TestGetEmployees()
        {
            Employee testEmployee = new Employee(Employee.GenerateNextEid(), "UnitTestEmployee", "UnitTestLname", "", "", 0);
            testEmployee.Insert();

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

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

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

            testEmployee.Delete();
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 10
0
 public void TestGetSetSpecialty()
 {
     Employee e = new Employee();
     e.Specialty = "Test";
     Assert.True(e.Specialty == "Test");
 }
Ejemplo n.º 11
0
 public void TestGetSetLname()
 {
     Employee e = new Employee();
     e.Lname = "Test";
     Assert.True(e.Lname == "Test");
 }
Ejemplo n.º 12
0
 public void TestGetSetType()
 {
     Employee e = new Employee();
     e.Employee_type = "Test";
     Assert.True(e.Employee_type == "Test");
 }
Ejemplo n.º 13
0
 public void TestGetSetSupervisor()
 {
     Employee e = new Employee();
     e.Supervisor_id = 1;
     Assert.True(e.Supervisor_id == 1);
 }
Ejemplo n.º 14
0
 public EmployeeInformation(Employee Employee)
 {
     InitializeComponent();
     _isNewEmployee = false;  //A new employee will not have an employee id to reference
     employee = Employee;
 }
Ejemplo n.º 15
0
 //Required for databinding -- END
 public EmployeeInformation()
 {
     InitializeComponent();
     employee = new Employee();
     generatedEID.Content = Employee.GenerateNextEid(); //Show the next EID when page loads
 }
Ejemplo n.º 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;
 }