Skip to content
Snippets Groups Projects
Commit 49894a49 authored by Lou's avatar Lou
Browse files

test done for classes grade and teachingUnitResults

parent d885efb9
No related branches found
No related tags found
No related merge requests found
Pipeline #16028 passed
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
......@@ -28,8 +28,7 @@ public class Grade {
*/
public double getValue() {
// TODO : change code
return 0.;
return this.value;
}
/**
......@@ -38,8 +37,7 @@ public class Grade {
*/
@Override
public String toString() {
// TODO : change code
return null;
return this.value + "/" + MAXIMUM_GRADE ;
}
/**
......@@ -50,8 +48,13 @@ public class Grade {
* @return a grade corresponding to the mean of grade in {@code grades}
*/
public static Grade averageGrade(List<Grade> grades){
// TODO : change code
return null;
double sumOfGrades = 0.0;
int nbOfStudents = grades.size();
for (Grade oneGrade : grades) {
sumOfGrades += oneGrade.value;
}
Grade averageGrade = new Grade(sumOfGrades / nbOfStudents);
return averageGrade;
}
/**
......
......@@ -26,8 +26,7 @@ public class TeachingUnitResult {
* @return the grade associated to the result
*/
public Grade getGrade() {
// TODO : change code
return null;
return this.grade;
}
/**
......@@ -36,8 +35,7 @@ public class TeachingUnitResult {
*/
@Override
public String toString() {
// TODO : change code
return null;
return this.teachingUnitName + " : " + this.grade.toString();
}
......
......@@ -33,14 +33,14 @@ class GradeTest {
.isNotEqualTo(20.0);
}
@Disabled("Disabled until Grade is coded")
//@Disabled("Disabled until Grade is coded")
@Test
void testGetValue() {
assertThat(twenty.getValue()).isCloseTo(20, within(EPSILON));
assertThat(zero.getValue()).isCloseTo(0, within(EPSILON));
}
@Disabled("Disabled until Grade is coded")
//@Disabled("Disabled until Grade is coded")
@Test
void testToString() {
assertThat(twenty.toString()).isEqualTo("20.0/20");
......@@ -48,7 +48,7 @@ class GradeTest {
}
@Disabled("Disabled until Grade is coded")
//@Disabled("Disabled until Grade is coded")
@Test
void testAverageGrade(){
assertThat(Grade.averageGrade(grades)).isEqualTo(ten);
......
......@@ -9,14 +9,14 @@ class TeachingUnitResultTest {
private static final TeachingUnitResult zeroAtStructDiscrete =
new TeachingUnitResult("Structures discrètes", GradeTest.zero);
@Disabled("Disabled until TeachingUnitResult is coded")
//@Disabled("Disabled until TeachingUnitResult is coded")
@Test
void testGetGrade() {
assertThat(twentyAtProg.getGrade()).isEqualTo(GradeTest.twenty);
assertThat(zeroAtStructDiscrete.getGrade()).isEqualTo(GradeTest.zero);
}
@Disabled("Disabled until TeachingUnitResult is coded")
//@Disabled("Disabled until TeachingUnitResult is coded")
@Test
void testToString() {
assertThat(twentyAtProg.toString()).isEqualTo("Programmation 2 : 20.0/20");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment