Browse Source

BordComputerTest.changeDeviceTest third case

feature-dev-BoardComputer2
sahar 2 years ago
parent
commit
af618f21a1
  1. 20
      src/main/java/BordComputer.java
  2. 11
      src/test/java/BordComputerTest.java

20
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;
}
}

11
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)
);
}
}
Loading…
Cancel
Save