C3PO Test
parent
4d9d654511
commit
11fd265348
|
@ -0,0 +1,56 @@
|
|||
package Domäne;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import tpe.exceptions.roboter.exceptions.RobotException;
|
||||
import tpe.exceptions.roboter.exceptions.RobotIllegalStateException;
|
||||
import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
|
||||
|
||||
class C3POTest {
|
||||
|
||||
@Test
|
||||
void getIdTest() {
|
||||
C3PO test = new C3PO("test", 123);
|
||||
assertEquals(123, test.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRobotTypeTest() {
|
||||
C3PO test = new C3PO("test", 123);
|
||||
assertEquals(RobotType.C3PO, test.getRobotType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void powerTest() {
|
||||
C3PO test = new C3PO("test", 123);
|
||||
int[] arr = { 1, 3, 5 };
|
||||
assertThrows(RobotIllegalStateException.class, () -> test.think(arr));
|
||||
}
|
||||
|
||||
@Test
|
||||
void magicValueTest() {
|
||||
C3PO test = new C3PO("test", 123);
|
||||
test.triggerPowerSwitch();
|
||||
int[] arr = { 1, 5, 42, 7, 15 };
|
||||
Throwable exception = assertThrows(RobotMagicValueException.class, () -> test.think(arr));
|
||||
assertEquals("Fehler! Zahl 42 im Array!", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void thinkTest() {
|
||||
C3PO test = new C3PO("test", 123);
|
||||
test.triggerPowerSwitch();
|
||||
int[] arr = { 1, 5, 43, 7, 15 };
|
||||
int[] ziel = { 43, 15, 7, 5, 1 };
|
||||
try {
|
||||
assertArrayEquals(ziel, test.think(arr));
|
||||
} catch (RobotException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Zahlen im Array sind ungültig!");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue