fixed tests
parent
3ca05973b8
commit
74c088e4fb
|
@ -3,6 +3,7 @@ package de.hsmannheim.informatik.name.domain.starwars;
|
|||
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 org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -10,15 +11,29 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
|
||||
|
||||
class SpeakTest {
|
||||
final R2D2 r2d2 = new R2D2(9999, "test");
|
||||
final C3PO c3po = new C3PO(19999, "test");
|
||||
|
||||
|
||||
SpeakTest() throws RobotIllegalStateException {
|
||||
private R2D2 r2d2;
|
||||
private C3PO c3po;
|
||||
@BeforeEach
|
||||
void setup() throws RobotIllegalStateException {
|
||||
r2d2 = new R2D2(9999, "test");
|
||||
c3po = new C3PO(19999, "test");
|
||||
r2d2.triggerPowerSwitch();
|
||||
c3po.triggerPowerSwitch();
|
||||
}
|
||||
|
||||
SpeakTest() throws RobotIllegalStateException {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void RobotOffSpeakTest() {
|
||||
r2d2.triggerPowerSwitch();
|
||||
c3po.triggerPowerSwitch();
|
||||
assertThrows(RobotIllegalStateException.class, () -> r2d2.speak(new int[1]));
|
||||
assertThrows(RobotIllegalStateException.class, () -> c3po.speak(new int[1]));
|
||||
}
|
||||
|
||||
@Test
|
||||
void R2D2SpeakTestStandard() throws RobotException {
|
||||
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}));
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.hsmannheim.informatik.name.domain.starwars;
|
|||
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 org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
@ -10,14 +11,28 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
|
||||
class ThinkTest {
|
||||
|
||||
private final R2D2 r2d2 = new R2D2(9999, "test");
|
||||
private final C3PO c3po = new C3PO(19999, "test");
|
||||
|
||||
ThinkTest() throws RobotIllegalStateException {
|
||||
private R2D2 r2d2;
|
||||
private C3PO c3po;
|
||||
@BeforeEach
|
||||
void setup() throws RobotIllegalStateException {
|
||||
r2d2 = new R2D2(9999, "test");
|
||||
c3po = new C3PO(19999, "test");
|
||||
r2d2.triggerPowerSwitch();
|
||||
c3po.triggerPowerSwitch();
|
||||
}
|
||||
|
||||
@Test
|
||||
void C3POTurnedOffThinkTest() {
|
||||
r2d2.triggerPowerSwitch();
|
||||
assertThrows(RobotIllegalStateException.class, () -> r2d2.think(new int[1]));
|
||||
}
|
||||
|
||||
@Test
|
||||
void R2D2TurnedOffThinkTest() {
|
||||
c3po.triggerPowerSwitch();
|
||||
assertThrows(RobotIllegalStateException.class, () -> c3po.think(new int[1]));
|
||||
}
|
||||
|
||||
@Test
|
||||
void thinkTestStandard() throws RobotException {
|
||||
assertArrayEquals(new int[]{0, 1, 2, 3, 4, 5}, r2d2.think(new int[]{3, 0, 1, 5, 2, 4}));
|
||||
|
|
Loading…
Reference in New Issue