Skip to content

Commit f841a2e

Browse files
committed
Complete the course unit test
1 parent cac9d8b commit f841a2e

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public boolean dropStudent() {
5151

5252

5353
public String getCourseLocation() {
54-
return this.instructorName;
54+
return this.courseLocation;
5555
}
5656

5757

5858
public String getInstructorName() {
59-
return this.courseLocation;
59+
return this.instructorName;
6060
}
6161

6262

@@ -92,7 +92,7 @@ public void setEnrolledStudentCount(int count) {
9292

9393

9494
public boolean isCourseFull() {
95-
return enrollmentCapacity > enrolledStudentCount;
95+
return enrollmentCapacity < enrolledStudentCount;
9696
}
9797

9898
@Serial

IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,70 @@ public void toStringTest() {
2929
assertEquals(expectedResult, testCourse.toString());
3030
}
3131

32+
@Test
33+
public void getCourseLocationTest() {
34+
assertEquals("417 IAB", testCourse.getCourseLocation());
35+
}
36+
37+
@Test
38+
public void getInstructorNameTest() {
39+
assertEquals("Griffin Newbold", testCourse.getInstructorName());
40+
}
41+
42+
@Test
43+
public void getCourseTimeSlotTest() {
44+
assertEquals("11:40-12:55", testCourse.getCourseTimeSlot());
45+
}
46+
47+
@Test
48+
public void reassignInstructorTest() {
49+
testCourse.reassignInstructor("Griffin BBB");
50+
assertEquals("Griffin BBB", testCourse.getInstructorName());
51+
// set the instructor name back to the original value
52+
testCourse.reassignInstructor("Griffin Newbold");
53+
}
54+
55+
@Test
56+
public void reassignLocationTest() {
57+
testCourse.reassignLocation("417 BBB");
58+
assertEquals("417 BBB", testCourse.getCourseLocation());
59+
// set the location back to the original value
60+
testCourse.reassignLocation("417 IAB");
61+
}
62+
63+
@Test
64+
public void reassignTimeTest() {
65+
testCourse.reassignTime("1:00-2:15");
66+
assertEquals("1:00-2:15", testCourse.getCourseTimeSlot());
67+
// set the time back to the original value
68+
testCourse.reassignTime("11:40-12:55");
69+
}
70+
71+
@Test
72+
public void isCourseFullTest() {
73+
assertEquals(true, testCourse.isCourseFull());
74+
}
75+
76+
@Test
77+
public void setEnrolledStudentCountTest() {
78+
testCourse.setEnrolledStudentCount(251);
79+
assertEquals(true, testCourse.isCourseFull());
80+
}
81+
82+
@Test
83+
public void enrollStudentTest() {
84+
testCourse.setEnrolledStudentCount(250);
85+
testCourse.enrollStudent();
86+
assertEquals(true, testCourse.isCourseFull());
87+
}
88+
89+
@Test
90+
public void dropStudentTest() {
91+
testCourse.setEnrolledStudentCount(251);
92+
testCourse.dropStudent();
93+
assertEquals(false, testCourse.isCourseFull());
94+
}
95+
3296
/** The test course instance used for testing. */
3397
public static Course testCourse;
3498
}

IndividualProject/src/test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java

Whitespace-only changes.

bugs.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Here I will list all the bugs that I found in the project and how I solve it.
2+
3+
1. `return enrollmentCapacity > enrolledStudentCount;`
4+
- Address: In isCourseFull() method in Course class.
5+
- Solution: Change the > to <.
6+
- Reason: The mothod should return false when the enrolledStudentCount is greater than or equal to the enrollmentCapacity.
7+
8+
2. `return this.instructorName;`
9+
- Address: In getCourseLocation() method in Course class.
10+
- Solution: Change instructorName to courseLocation.
11+
- Reason: The method should return the courseLocation, not the instructorName.
12+
13+
3. `return this.courseLocation;`
14+
- Address: In getInstructorName() method in Course class.
15+
- Solution: Change courseLocation to instructorName.
16+
- Reason: The method should return the instructorName, not the courseLocation.

0 commit comments

Comments
 (0)