From 614e31e845244576c8c0f127eace28025ddcf6f9 Mon Sep 17 00:00:00 2001 From: fdai7887 Date: Thu, 8 Feb 2024 23:45:27 +0100 Subject: [PATCH] Added test for calculateTotalCredits Method in StudentTest class --- src/test/java/org/example/StudentTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java index 6e2abaf..30231f2 100644 --- a/src/test/java/org/example/StudentTest.java +++ b/src/test/java/org/example/StudentTest.java @@ -108,4 +108,19 @@ class StudentTest { assertEquals(newGrade, student.getCourseGrades().get(course), "Grade update for course does not match expected new grade."); } + @Test + void calculateTotalCredits(){ + Administration admin = new Administration(); + Student student = new Student("John Doe", "S1001", "Student"); + Course course = new Course("Introduction to Java", "C101", 3); + admin.addStudents(student); + admin.addCourse(course); + admin.enrollStudentInCourse("S1001", "C101"); + + int credits = student.calculateTotalCredits(); + + assertEquals(3,credits); + + } + } \ No newline at end of file