public bool test3() //search for professor (Britton Wolfe) while Software is written in regular search box; courseID's are 186, 187 { Search search = Search.Create("course_database.txt"); CourseInfo DB = CourseInfo.Create(); search.options.clear(); search.options.firstNameProfessor = "Britton"; search.options.lastNameProfessor = "Wolfe"; search.searchForQuery("Software"); search.advancedSearchFilter(); if (search.lastSearchResults.getCourses().Count != 2) { return(false); } foreach (var course in search.lastSearchResults.getCourses()) { int courseID = course.getCourseID(); if (courseID != 186 && courseID != 187) { return(false); } } return(true); }
public bool test2() //search database with nothing entered (all courses in database will be returned); course ID's are 0 through 760 { Search search = Search.Create("course_dictionary.txt"); CourseInfo DB = CourseInfo.Create(); search.options.clear(); search.options.firstNameProfessor = ""; search.options.lastNameProfessor = ""; search.searchForQuery(""); search.advancedSearchFilter(); int i = 0; foreach (var course in search.lastSearchResults.getCourses()) { if (i++ != course.getCourseID()) { return(false); } } if (i != DB.getNumCourses()) { return(false); } if (i != 761) { return(false); } return(true); }
//all tests are based on requirement 7 (professor searching) of the sprint 1 testing plan, tests b-d public bool test1() //searching for a specific professor (Britton Wolfe); courseIDs should be 184, 186, and 187. { Search search = Search.Create("course_database.txt"); CourseInfo DB = CourseInfo.Create(); search.options.clear(); search.options.firstNameProfessor = "Britton"; search.options.lastNameProfessor = "Wolfe"; search.searchForQuery(null); search.advancedSearchFilter(); foreach (var course in search.lastSearchResults.getCourses()) { int courseID = course.getCourseID(); if (courseID != 184 && courseID != 186 && courseID != 187) { return(false); } } if (search.lastSearchResults.getCourses().Count != 3) { return(false); } return(true); }
static void Main(string[] args) { CourseInfo database = CourseInfo.Create("course_database.txt", "rmp_database.txt"); // Creates CourseInfo singleton Search search = Search.Create("course_dictionary.txt"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ScheduleApp.AppWindow()); UnitTests test = new UnitTests(); // This code is for testing the course search and spell-checking features // Creates an instance of the Search class using course_dictionary.txt for spell-checking and mini course database //Search search = new Search("course_dictionary.txt"); Console.WriteLine("Running Test 1...\n "); printSuccess(test.test1()); Console.WriteLine("Running Test 2...\n "); printSuccess(test.test2()); Console.WriteLine("Running Test 3...\n "); printSuccess(test.test3()); }
/**********************Text Inside Search****************************************/ #region // Displays the last thing the user entered in the search box when search box is clicked private void searchBox_Enter(object sender, EventArgs e) { searchBox.Text = Search.Create().lastSearchResults.getQuery(); // calls search if user presses enter instead of the search button searchBox.ForeColor = Color.Black; }