RobotFactoryTest Klasse mit Tests implementiert.

master
Milan Lukic 2023-01-06 17:29:01 +01:00
parent b56e302e37
commit c218cace87
2 changed files with 59 additions and 0 deletions

View File

@ -82,4 +82,8 @@ public RobotFactory (String name) {
return ausgabe; return ausgabe;
} }
public int getRoboterLagerSize() {
return roboterLager.size();
}
} }

View File

@ -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));
}
}