From be76e39089db567b11fff63be674464a8d549eaa Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Thu, 8 Feb 2024 21:52:55 +0100 Subject: [PATCH] test: Added testEnrollStudentInteractive Function --- .../java/org/example/AdministrationTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 0397e89..f376603 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/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 courses = stud.getCourseGrades(); + + for(Course key : courses.keySet()) + { + if(key == course) + { + correct = true; + break; + } + } + + assertTrue(correct); + } }