RobotFactory/tests/R2D2SpeakTest.java

46 lines
1.5 KiB
Java

import de.hsmannheim.informatik.name.domain.exceptions.RobotException;
import de.hsmannheim.informatik.name.domain.exceptions.RobotIllegalStateException;
import de.hsmannheim.informatik.name.domain.exceptions.RobotMagicValueException;
import de.hsmannheim.informatik.name.domain.starwars.R2D2;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class R2D2SpeakTest {
private final R2D2 r2d2 = new R2D2(9999);
R2D2SpeakTest() throws RobotIllegalStateException {
}
@Test
void speakTestStandard() throws RobotException, RobotMagicValueException {
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
void speakTestEmpty() throws RobotException, RobotMagicValueException {
assertEquals("", r2d2.speak(new int[]{}));
}
@Test
void speakTestZeros() throws RobotException, RobotMagicValueException {
assertEquals("0, 0, 0, 0", r2d2.speak(new int[4]));
}
@Test
void speakTestOneElement() throws RobotException, RobotMagicValueException {
assertEquals("1", r2d2.speak(new int[]{1}));
}
@Test
void speakTestUnitElements() throws RobotException, RobotMagicValueException {
assertEquals("-1, 0, 1", r2d2.speak(new int[]{-1, 0, 1}));
}
@Test
void speakTestMagicNumberException() throws RobotException {
assertThrows(RobotMagicValueException.class, () -> r2d2.speak(new int[]{42}));
}
}