diff --git a/Roboterfabrik/src/Domäne/RobotFactory.java b/Roboterfabrik/src/Domäne/RobotFactory.java index dfa8b58..2272cd8 100644 --- a/Roboterfabrik/src/Domäne/RobotFactory.java +++ b/Roboterfabrik/src/Domäne/RobotFactory.java @@ -82,4 +82,8 @@ public RobotFactory (String name) { return ausgabe; } + + public int getRoboterLagerSize() { + return roboterLager.size(); + } } diff --git a/Roboterfabrik/src/Domäne/RobotFactoryTest.java b/Roboterfabrik/src/Domäne/RobotFactoryTest.java new file mode 100644 index 0000000..a321f80 --- /dev/null +++ b/Roboterfabrik/src/Domäne/RobotFactoryTest.java @@ -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)); + } + +}