|
@ -1,5 +1,7 @@ |
|
|
import device.Device; |
|
|
import device.Device; |
|
|
|
|
|
import device.cdPlayer.CDPlayer; |
|
|
import device.radioPlayer.RadioPlayer; |
|
|
import device.radioPlayer.RadioPlayer; |
|
|
|
|
|
import device.usbPlayer.UsbPlayer; |
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
@ -35,7 +37,7 @@ class BordComputerTest { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> readConfigOptions() { |
|
|
|
|
|
|
|
|
static Stream<Arguments> readConfigOptions() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { |
|
|
BordComputer bc1 = new BordComputer(); |
|
|
BordComputer bc1 = new BordComputer(); |
|
|
bc1.readConfig(); |
|
|
bc1.readConfig(); |
|
|
|
|
|
|
|
@ -50,24 +52,24 @@ class BordComputerTest { |
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("setDevicesOptions") |
|
|
@MethodSource("setDevicesOptions") |
|
|
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); |
|
|
|
|
|
|
|
|
void setDevicesTest(String testName, BordComputer testBc, String testTyp, Boolean bool) { |
|
|
|
|
|
Boolean boolActual = null; |
|
|
|
|
|
if (testTyp.equals("0")) boolActual = (testBc.installedDevices[0] instanceof CDPlayer); |
|
|
|
|
|
if (testTyp.equals("1")) boolActual = (testBc.installedDevices[1] instanceof RadioPlayer); |
|
|
|
|
|
if (testTyp.equals("2")) boolActual = (testBc.installedDevices[2] instanceof UsbPlayer); |
|
|
|
|
|
assertThat(boolActual).describedAs(testName).isEqualTo(bool); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> setDevicesOptions() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { |
|
|
static Stream<Arguments> setDevicesOptions() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { |
|
|
BordComputer bc = new BordComputer(); |
|
|
BordComputer bc = new BordComputer(); |
|
|
bc.readConfig(); |
|
|
bc.readConfig(); |
|
|
bc.setDevices(); |
|
|
|
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
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") |
|
|
|
|
|
|
|
|
Arguments.of("Test if installedDevices[0] is instance of CDPlayer", bc, "0", true), |
|
|
|
|
|
Arguments.of("Test if installedDevices[1] is instance of RadioPlayer", bc, "1", true), |
|
|
|
|
|
Arguments.of("Test if installedDevices[2] is instance of UsbPlayer", bc, "2", true) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int fileReaderCount() { |
|
|
public int fileReaderCount() { |
|
|
int count = 0; |
|
|
int count = 0; |
|
|
try (FileReader reader = new FileReader("Geraete.config")) { |
|
|
try (FileReader reader = new FileReader("Geraete.config")) { |
|
@ -76,6 +78,7 @@ class BordComputerTest { |
|
|
count = properties.size(); |
|
|
count = properties.size(); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} return count; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return count; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |