RobotFactoryTest Klasse mit Tests implementiert.
parent
b56e302e37
commit
c218cace87
|
@ -82,4 +82,8 @@ public RobotFactory (String name) {
|
|||
return ausgabe;
|
||||
|
||||
}
|
||||
|
||||
public int getRoboterLagerSize() {
|
||||
return roboterLager.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package Domäne;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import tpe.exceptions.roboter.exceptions.RobotException;
|
||||
|
||||
class RobotFactoryTest {
|
||||
private static RobotFactory rf;
|
||||
|
||||
|
||||
@BeforeAll
|
||||
static void initRobotFactory() {
|
||||
rf = new RobotFactory ("Test");
|
||||
}
|
||||
@Test
|
||||
void smokeTest() {
|
||||
assertNotNull(rf);
|
||||
assertEquals(1, rf.getRoboterLagerSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addRoboterTest() {
|
||||
int id = rf.addRobot(RobotType.R2D2, "Test");
|
||||
assertEquals(2, rf.getRoboterLagerSize());
|
||||
int id2 = rf.addRobot(RobotType.C3PO, "Test2");
|
||||
assertEquals(3, rf.getRoboterLagerSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
void zustandTest() {
|
||||
int id = rf.addRobot(RobotType.R2D2, "Test");
|
||||
assertFalse(rf.roboterZustand(id));
|
||||
rf.schalterAnAus(id);
|
||||
assertTrue(rf.roboterZustand(id));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void aufrufSpeakAndThinkTest() throws RobotException {
|
||||
int id = rf.addRobot(RobotType.R2D2, "Test");
|
||||
rf.schalterAnAus(id);
|
||||
int [] zahlen = {5,8,4,3,7};
|
||||
assertEquals("3, 4, 5, 7, 8, ",rf.aufrufSpeakAndThink(id, zahlen));
|
||||
}
|
||||
|
||||
@Test
|
||||
void datenDesRobotersTest() {
|
||||
int id = rf.addRobot(RobotType.R2D2, "Test");
|
||||
assertEquals("RoboterType: " + "R2D2" + "; Name: " +"Test" + "; Seriennummer: " + id, rf.datenDesRoboters(id));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue