diff --git a/src/main/java/BordComputer.java b/src/main/java/BordComputer.java index dbf777c..5f92057 100644 --- a/src/main/java/BordComputer.java +++ b/src/main/java/BordComputer.java @@ -29,7 +29,9 @@ public class BordComputer { public void setDevices() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, ClassNotFoundException { Class c; - c= Class.forName(deviceNames[0]); - installedDevices[0] = (Device) c.getConstructor().newInstance(); + for(int i = 0;i < deviceNames.length; i++) { + c = Class.forName(deviceNames[i]); + installedDevices[i] = (Device) c.getConstructor().newInstance(); + } } } diff --git a/src/test/java/BordComputerTest.java b/src/test/java/BordComputerTest.java index 834a958..8a38b9b 100644 --- a/src/test/java/BordComputerTest.java +++ b/src/test/java/BordComputerTest.java @@ -50,8 +50,11 @@ class BordComputerTest { @ParameterizedTest @MethodSource("setDevicesOptions") - void setDevicesTest(String testName, BordComputer testBc) { - Device dev = testBc.installedDevices[0]; + void setDevicesTest(String testName, BordComputer testBc, String testTyp) { + Device dev = null; + if(testTyp.equals("0")) dev = testBc.installedDevices[0]; + if(testTyp.equals("1")) dev = testBc.installedDevices[1]; + if(testTyp.equals("2")) dev = testBc.installedDevices[2]; assertThat(dev).describedAs(testName).isNotEqualTo(null); } @@ -60,8 +63,9 @@ class BordComputerTest { bc.readConfig(); bc.setDevices(); return Stream.of( - Arguments.of("Test if installedDevices[0] is not null", bc) - + Arguments.of("Test if installedDevices[0] is not null", bc, "0"), + Arguments.of("Test if installedDevices[1] is not null", bc, "1"), + Arguments.of("Test if installedDevices[2] is not null", bc, "2") ); } public int fileReaderCount() {