|
@ -3,6 +3,7 @@ package org.example; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
@ -418,4 +419,32 @@ class AdministrationTest { |
|
|
assertEquals("Student",administration.findStudentById("S1010").getStudentRole()); |
|
|
assertEquals("Student",administration.findStudentById("S1010").getStudentRole()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testEnrollStudentInCourseInteractive() { |
|
|
|
|
|
Administration administration = new Administration(); |
|
|
|
|
|
|
|
|
|
|
|
Student stud = sampleStudent; |
|
|
|
|
|
administration.addStudents(stud); |
|
|
|
|
|
Course course = sampleCourse; |
|
|
|
|
|
administration.addCourse(course); |
|
|
|
|
|
String studentId =stud.getStudentId(); // Use nextLine for consistent input handling |
|
|
|
|
|
String courseId = course.getCourseID(); |
|
|
|
|
|
|
|
|
|
|
|
boolean enrolled = administration.enrollStudentInCourse(studentId, courseId); |
|
|
|
|
|
|
|
|
|
|
|
boolean correct = false; |
|
|
|
|
|
Map<Course, String> courses = stud.getCourseGrades(); |
|
|
|
|
|
|
|
|
|
|
|
for(Course key : courses.keySet()) |
|
|
|
|
|
{ |
|
|
|
|
|
if(key == course) |
|
|
|
|
|
{ |
|
|
|
|
|
correct = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assertTrue(correct); |
|
|
|
|
|
} |
|
|
} |
|
|
} |