package grades;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

class ScoresTest {

    @Test
    void highestOfSeveral() {
        Scores scores = new Scores(new int[] {14, 17, 11});

        assertEquals(17, scores.highest());
    }

    @Test
    void rejectsScoreAboveTwenty() {
        assertThrows(IllegalArgumentException.class, () -> new Scores(new int[] {14, 21}));
    }

    @Test
    void changingTheReturnedArrayDoesNotChangeTheScores() {
        Scores scores = new Scores(new int[] {14, 17, 11});

        scores.values()[0] = 99;

        assertEquals(14, scores.values()[0]);
        assertEquals(17, scores.highest());
    }

    @Test
    void changingTheInputArrayDoesNotChangeTheScores() {
        int[] input = {14, 17, 11};
        Scores scores = new Scores(input);

        input[1] = -5;

        assertEquals(17, scores.values()[1]);
    }
}
