2022-12-20 14:24:11 +01:00
|
|
|
import de.hsmannheim.informatik.name.domain.exceptions.RobotException;
|
2022-12-21 13:55:39 +01:00
|
|
|
import de.hsmannheim.informatik.name.domain.exceptions.RobotIllegalStateException;
|
|
|
|
import de.hsmannheim.informatik.name.domain.exceptions.RobotMagicValueException;
|
2022-12-20 14:24:11 +01:00
|
|
|
import de.hsmannheim.informatik.name.domain.starwars.R2D2;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
2022-12-21 13:55:39 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
2022-12-20 14:24:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
class R2D2SpeakTest {
|
|
|
|
|
2022-12-21 13:55:39 +01:00
|
|
|
private final R2D2 r2d2 = new R2D2(9999);
|
|
|
|
|
|
|
|
R2D2SpeakTest() throws RobotIllegalStateException {
|
|
|
|
}
|
2022-12-20 14:24:11 +01:00
|
|
|
|
|
|
|
@Test
|
2022-12-21 13:55:39 +01:00
|
|
|
void speakTestStandard() throws RobotException, RobotMagicValueException {
|
2022-12-20 14:24:11 +01:00
|
|
|
assertEquals("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12", r2d2.speak(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2022-12-21 13:55:39 +01:00
|
|
|
void speakTestEmpty() throws RobotException, RobotMagicValueException {
|
2022-12-20 14:24:11 +01:00
|
|
|
assertEquals("", r2d2.speak(new int[]{}));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2022-12-21 13:55:39 +01:00
|
|
|
void speakTestZeros() throws RobotException, RobotMagicValueException {
|
2022-12-20 14:24:11 +01:00
|
|
|
assertEquals("0, 0, 0, 0", r2d2.speak(new int[4]));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2022-12-21 13:55:39 +01:00
|
|
|
void speakTestOneElement() throws RobotException, RobotMagicValueException {
|
2022-12-20 14:24:11 +01:00
|
|
|
assertEquals("1", r2d2.speak(new int[]{1}));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2022-12-21 13:55:39 +01:00
|
|
|
void speakTestUnitElements() throws RobotException, RobotMagicValueException {
|
2022-12-20 14:24:11 +01:00
|
|
|
assertEquals("-1, 0, 1", r2d2.speak(new int[]{-1, 0, 1}));
|
|
|
|
}
|
2022-12-21 13:55:39 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void speakTestMagicNumberException() throws RobotException {
|
|
|
|
assertThrows(RobotMagicValueException.class,() -> r2d2.speak(new int[]{42}));
|
|
|
|
}
|
2022-12-20 14:24:11 +01:00
|
|
|
}
|