|
|
@ -107,6 +107,31 @@ class CourseTest { |
|
|
|
deleteTempFile(); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void addCourse() { |
|
|
|
// Create a new course |
|
|
|
String courseName = "Math"; |
|
|
|
String courseCode = "C101"; |
|
|
|
int courseCredit = 3; |
|
|
|
|
|
|
|
// Write course data to the temporary file |
|
|
|
Course.addCourse(courseName, courseCode, courseCredit, TEMP_FILE); |
|
|
|
|
|
|
|
// Read course data from the temporary file |
|
|
|
List<Course> courses = Course.readFromFile(TEMP_FILE); |
|
|
|
|
|
|
|
// Assert that the course is added successfully |
|
|
|
assertEquals(1, courses.size()); |
|
|
|
Course addedCourse = courses.get(0); |
|
|
|
assertEquals(courseName, addedCourse.getCourseName()); |
|
|
|
assertEquals(courseCode, addedCourse.getCourseCode()); |
|
|
|
assertEquals(courseCredit, addedCourse.getCourseCredit()); |
|
|
|
|
|
|
|
// Delete the temporary file |
|
|
|
deleteTempFile(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Creates a temporary file with the provided data. |
|
|
|
* |
|
|
|