CedricNew 2023-01-10 01:41:48 +01:00
commit b9608f1cdd
7 changed files with 19 additions and 5 deletions

View File

@ -11,7 +11,6 @@ public class Factory implements Serializable {
private int r2d2ID = 10000; private int r2d2ID = 10000;
public Factory(){ public Factory(){
} }
/** /**
* @return Collection<Robot></Robot> * @return Collection<Robot></Robot>

View File

@ -1,26 +1,41 @@
package tests; package tests;
import domain.Robot;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import domain.C3PO;
import domain.Factory;
import domain.RobotType;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class FactoryTest { class FactoryTest {
@Test Factory f;
void robotListToCollection() { @BeforeEach
void setup(){
f = new Factory();
f.buildNewRobot("herbi", RobotType.C3PO);
f.buildNewRobot("Herta", RobotType.R2D2);
} }
@Test @Test
void getRobotList() { void getRobotList() {
assertEquals(2, f.getRobotList().length);
f.buildNewRobot("Herbi3", RobotType.C3PO);
assertEquals(3, f.getRobotList().length);
} }
@Test @Test
void buildNewRobot() { void buildNewRobot() {
boolean test = f.buildNewRobot("herbi", RobotType.R2D2);
assertEquals(true, test);
} }
@Test @Test
void getRobotOfList() { void getRobotOfList() {
Robot r = f.getRobotOfList(0);
assertEquals( "herbi",r.getName());
} }
} }