Browse Source

BordComputerTest.changeDeviceTest forth case

feature-dev-BoardComputerTests
sahar 3 years ago
parent
commit
987ee9a280
  1. 21
      src/main/java/BordComputer.java
  2. 14
      src/test/java/BordComputerTest.java

21
src/main/java/BordComputer.java

@ -1,4 +1,6 @@
import device.Device; import device.Device;
import device.cdPlayer.CD;
import device.cdPlayer.CDPlayer;
import java.io.FileReader; import java.io.FileReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -45,7 +47,24 @@ public class BordComputer {
installedDevices=tempDevices; installedDevices=tempDevices;
//setting activeDevice //setting activeDevice
activeDevice =installedDevices[0]; activeDevice =installedDevices[0];
return activeDevice.getInfoText()+" ist activate";
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;
} }
} }

14
src/test/java/BordComputerTest.java

@ -1,4 +1,5 @@
import device.Device; import device.Device;
import device.cdPlayer.CD;
import device.cdPlayer.CDPlayer; import device.cdPlayer.CDPlayer;
import device.radioPlayer.RadioPlayer; import device.radioPlayer.RadioPlayer;
import device.usbPlayer.USB_Stick; import device.usbPlayer.USB_Stick;
@ -94,6 +95,8 @@ class BordComputerTest {
assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice); assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice);
}else if (caseNr == 3) { }else if (caseNr == 3) {
assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull(); assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull();
}else if (caseNr == 4) {
assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull();
} }
} }
@ -120,11 +123,20 @@ class BordComputerTest {
bc2.setDevices(); bc2.setDevices();
m =bc2.changeDevice(); m =bc2.changeDevice();
//forth case
BordComputer bc3 = new BordComputer();
bc3.readConfig();
bc3.setDevices();
m =bc3.changeDevice();
m =bc3.changeDevice(); //CDPlayer
return Stream.of( return Stream.of(
Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,"",1), 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)
Arguments.of("The new Device returns a String ", bc2,null,prvDevice,bc2.activeDevice.toString(),3),
Arguments.of("The new Device returns a String ", bc3,null,prvDevice,null,4)
); );
} }

Loading…
Cancel
Save