From af618f21a189b90db3e7d04d3ab0b8297b011c4d Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 18 Feb 2022 19:43:58 +0100 Subject: [PATCH] BordComputerTest.changeDeviceTest third case --- src/main/java/BordComputer.java | 20 +++++++++++++++++++- src/test/java/BordComputerTest.java | 11 ++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/BordComputer.java b/src/main/java/BordComputer.java index 38d24d1..439078e 100644 --- a/src/main/java/BordComputer.java +++ b/src/main/java/BordComputer.java @@ -1,4 +1,6 @@ import device.Device; +import device.cdPlayer.CD; +import device.cdPlayer.CDPlayer; import java.io.FileReader; import java.lang.reflect.InvocationTargetException; @@ -46,6 +48,22 @@ public class BordComputer { //setting activeDevice activeDevice = installedDevices[0]; - return null; + String infoText=""; + if(activeDevice instanceof CDPlayer){ + CDPlayer cdPlayer=(CDPlayer) activeDevice; + String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"}; + //some CDs + CD audioCD1=new CD("Audio",audioPlayList); + audioCD1.setAlbumName("Love Songs"); + + cdPlayer.tapOnCdFlap(); + cdPlayer.setCD(audioCD1); + cdPlayer.tapOnCdFlap(); + cdPlayer.setInfoText(); + infoText = cdPlayer.getInfoText(); + }else{ + infoText=activeDevice.getInfoText()+" ist activate"; + } + return infoText; } } diff --git a/src/test/java/BordComputerTest.java b/src/test/java/BordComputerTest.java index 056b5f3..422d7ef 100644 --- a/src/test/java/BordComputerTest.java +++ b/src/test/java/BordComputerTest.java @@ -92,6 +92,8 @@ class BordComputerTest { }else if (caseNr == 2) { Device currentDevice = inputBC.activeDevice; assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice); + }else if (caseNr == 3) { + assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull(); } } @@ -112,11 +114,18 @@ class BordComputerTest { Device prvDevice = bc1.activeDevice; m =bc1.changeDevice(); + //third case + BordComputer bc2 = new BordComputer(); + bc2.readConfig(); + bc2.setDevices(); + m =bc2.changeDevice(); + return Stream.of( Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,"",1), - Arguments.of("The active Device should be changed ", bc1,null,prvDevice,"",2) + Arguments.of("The active Device should be changed ", bc1,null,prvDevice,"",2), + Arguments.of("The new Device returns a String ", bc2,null,prvDevice,bc2.activeDevice.toString(),3) ); } } \ No newline at end of file