public void TestSearchEmployeesWithValidQueryWithCloseEid() { 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("eid"); List<string> s = new List<string>(); int test = eid1 / 10; s.Add(test.ToString()); 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 TestGetBuiltQuery() { Search s = new Search("Test"); string q = s.GetBuiltQuery(); Assert.True(q.Equals("SELECT * FROM Test WHERE ")); }
public void TestBuildStringQueryWithTwoArguments() { Search s = new Search("Patient"); s.BuildStringQuery("Test Arg1", "Test Arg2"); string q = s.GetBuiltQuery(); Assert.True(q.Equals("SELECT * FROM Patient WHERE (Test Arg1 LIKE '%Test Arg2%')")); }
public void TestBuildStringQueryWithSingleArgument() { Search s = new Search("Patient"); s.BuildStringQuery("Test Arg"); string q = s.GetBuiltQuery(); Assert.True(q.Equals("SELECT * FROM Patient WHERE Test Arg")); }
public void validateInputs() { Search advancedSearch = new Search("Employee"); List<string> dbSideVariables = new List<string>(); List<string> cSideVariables = new List<string>(); #region Box Checking if (!string.IsNullOrWhiteSpace(tbEID.Text)) { dbSideVariables.Add("eid"); cSideVariables.Add(tbEID.Text); } if (!string.IsNullOrWhiteSpace(tbFName.Text)) { dbSideVariables.Add("fname"); cSideVariables.Add(tbFName.Text); } if (!string.IsNullOrWhiteSpace(tbLName.Text)) { dbSideVariables.Add("lname"); cSideVariables.Add(tbLName.Text); } if (!string.IsNullOrWhiteSpace(cbSpecialty.Text)) { dbSideVariables.Add("specialty"); cSideVariables.Add(cbSpecialty.Text); } if (!string.IsNullOrWhiteSpace(cbEmployeeType.Text)) { dbSideVariables.Add("employee_type"); cSideVariables.Add(cbEmployeeType.Text); } if (!string.IsNullOrWhiteSpace(tbSupervisorID.Text)) { dbSideVariables.Add("supervisor_id"); cSideVariables.Add(tbSupervisorID.Text); } #endregion advancedSearch.UseInputs(dbSideVariables, cSideVariables); Employees = Search.SearchEmployees(advancedSearch.GetBuiltQuery()); Employee_DataGrid.DataContext = Employees; }
public void TestUseInputs() { List<string> db = new List<string>(); db.Add("DB Test1"); db.Add("DB Test2"); List<string> s = new List<string>(); s.Add("S Test1"); s.Add("S Test2"); Search search = new Search("Test"); search.UseInputs(db, s); string expected = "SELECT * FROM Test WHERE (DB Test1 LIKE '%S Test1%') AND (DB Test2 LIKE '%S Test2%')"; string actual = search.GetBuiltQuery(); Assert.True(actual.Equals(expected)); }
public void TestSearchPatientWithValidQueryByMultipleExactParamters() { Patient p1 = new Patient(10000, "SearchFname1", "SearchLname1", new DateTime(), "Test Address", "Test City1", "Test Provice", "TEST", "1111111111", "2222222222", "3333333333"); p1.Insert(); p1.Select(); Patient p2 = new Patient(20000, "SearchFname2", "SearchLname2", new DateTime(), "Test Address", "Test City2", "Test Provice", "TEST", "4444444444", "5555555555", "6666666666"); p2.Insert(); p2.Select(); List<string> db = new List<string>(); db.Add("fname"); db.Add("lname"); db.Add("city"); List<string> s = new List<string>(); s.Add("SearchFname1"); s.Add("SearchLname1"); s.Add("Test City1"); Search search = new Search("Patient"); search.UseInputs(db, s); List<Patient> p = Search.SearchPatient(search.GetBuiltQuery()); //Assert.True(p[0].PatientID == p1.PatientID); p1.Delete(); p2.Delete(); }
public void TestSearchPatientWithValidQueryByCloseProvice() { Patient p1 = new Patient(10000, "SearchFname1", "SearchLname1", new DateTime(), "Test Address", "Test City", "Test Provice", "TEST", "1111111111", "2222222222", "3333333333"); p1.Insert(); p1.Select(); Patient p2 = new Patient(20000, "SearchFname2", "SearchLname2", new DateTime(), "Test Address", "Test City", "Test Provice", "TEST", "4444444444", "5555555555", "6666666666"); p2.Insert(); p2.Select(); List<string> db = new List<string>(); db.Add("province"); List<string> s = new List<string>(); s.Add("Test"); Search search = new Search("Patient"); search.UseInputs(db, s); List<Patient> p = Search.SearchPatient(search.GetBuiltQuery()); Assert.True(p.Count >= 2); p1.Delete(); p2.Delete(); }
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(); }
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(); }
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(); }
public void validateInputs() { Search advancedSearch = new Search("Patient"); List<string> dbSideVariables = new List<string>(); List<string> cSideVariables = new List<string>(); #region Box Checking if (!string.IsNullOrWhiteSpace(tbHealthCare.Text)) { cSideVariables.Add(tbHealthCare.Text); dbSideVariables.Add("hc_no"); } if (!string.IsNullOrWhiteSpace(tbFName.Text)) { cSideVariables.Add(tbFName.Text); dbSideVariables.Add("fname"); } if (!string.IsNullOrWhiteSpace(tbLName.Text)) { cSideVariables.Add(tbLName.Text); dbSideVariables.Add("lname"); } if (!(dpDOB.SelectedDate == null)) { cSideVariables.Add(dpDOB.SelectedDate.Value.Day.ToString()); cSideVariables.Add(dpDOB.SelectedDate.Value.Month.ToString()); cSideVariables.Add(dpDOB.SelectedDate.Value.Year.ToString()); dbSideVariables.Add("dob_day"); dbSideVariables.Add("dob_month"); dbSideVariables.Add("dob_year"); } if (!string.IsNullOrWhiteSpace(tbAddress.Text)) { cSideVariables.Add(tbAddress.Text); dbSideVariables.Add("street_address"); } if (!string.IsNullOrWhiteSpace(tbCity.Text)) { cSideVariables.Add(tbCity.Text); dbSideVariables.Add("city"); } if (!string.IsNullOrWhiteSpace(tbProvince.Text)) { cSideVariables.Add(tbProvince.Text); dbSideVariables.Add("province"); } if (!string.IsNullOrWhiteSpace(tbPostalCode.Text)) { cSideVariables.Add(tbPostalCode.Text); dbSideVariables.Add("postal_code"); } if (!string.IsNullOrWhiteSpace(tbPhoneNumber.Text)) { cSideVariables.Add(tbPhoneNumber.Text); dbSideVariables.Add("home_phone_no"); } #endregion advancedSearch.UseInputs(dbSideVariables, cSideVariables); Patients = Search.SearchPatient(advancedSearch.GetBuiltQuery()); Patients_DataGrid.DataContext = Patients; }