RoboterTest Klasse mit Tests erstellt.
parent
c218cace87
commit
38341c1c60
|
@ -9,9 +9,9 @@ import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
|
|||
|
||||
public abstract class Roboter implements Robot {
|
||||
|
||||
final String name;
|
||||
boolean power;
|
||||
RobotException fehler;
|
||||
protected final String name;
|
||||
protected boolean power;
|
||||
protected RobotException fehler;
|
||||
|
||||
// Roboter wird in einem ausgeschalteten Zustand instanziiert!
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package Domäne;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import tpe.exceptions.roboter.exceptions.RobotException;
|
||||
|
||||
class RoboterTest {
|
||||
|
||||
@Test
|
||||
void smokeTest() {
|
||||
Roboter roboter = new R2D2("Test", 1);
|
||||
assertEquals(roboter.getName(), "Test");
|
||||
assertEquals(1,roboter.getId());
|
||||
}
|
||||
@Test
|
||||
void triggerPowerSwitchTest() {
|
||||
Roboter r2d2 = new R2D2("Test", 1);
|
||||
Roboter c3po = new C3PO("Test", 15000);
|
||||
assertFalse(r2d2.isPowerOn());
|
||||
assertFalse(c3po.isPowerOn());
|
||||
r2d2.triggerPowerSwitch();
|
||||
assertTrue(r2d2.isPowerOn());
|
||||
assertFalse(c3po.isPowerOn());
|
||||
c3po.triggerPowerSwitch();
|
||||
assertTrue(r2d2.isPowerOn());
|
||||
assertTrue(c3po.isPowerOn());
|
||||
|
||||
}
|
||||
|
||||
void getLastExceptionTest() {
|
||||
Roboter r2d2 = new R2D2("Test", 1);
|
||||
int [] zahlen = {5,4,8,1};
|
||||
assertNull(r2d2.getLastException());
|
||||
try {
|
||||
r2d2.think(zahlen);
|
||||
} catch (RobotException e) {
|
||||
} assertNotNull(r2d2.getLastException());
|
||||
}
|
||||
|
||||
void nexus6SingletonTest() {
|
||||
Roboter pris = Nexus6.getInstance();
|
||||
Roboter pris2 = Nexus6.getInstance();
|
||||
assertEquals(pris.hashCode(), pris2.hashCode());
|
||||
assertEquals(pris, pris2);
|
||||
assertFalse(pris.isPowerOn());
|
||||
pris.triggerPowerSwitch();
|
||||
assertFalse(pris.isPowerOn());
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue