Browse Source

test: Added testEnrollStudentInteractive Function

remotes/origin/fdai7780
Tobias Herbert 11 months ago
parent
commit
be76e39089
  1. 29
      src/test/java/org/example/AdministrationTest.java

29
src/test/java/org/example/AdministrationTest.java

@ -3,6 +3,7 @@ package org.example;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
@ -418,4 +419,32 @@ class AdministrationTest {
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);
}
}
Loading…
Cancel
Save