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

            testEmployee.Delete();
        }
Example #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();
        }
Example #3
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();
        }
Example #4
0
        public void TestEmployeeUpdate()
        {
            Employee testEmployee = new Employee(Employee.GenerateNextEid(), "UnitTestEmployee", "UnitTestLname", "", "", 0);
            testEmployee.Insert();

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

            testEmployee.Delete();
        }
Example #5
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();
        }
Example #6
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();
        }
Example #7
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();
        }