From 987ee9a2803d6a46b32a1a332443a55a217b5cf9 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 18 Feb 2022 16:44:48 +0100 Subject: [PATCH] BordComputerTest.changeDeviceTest forth case --- src/main/java/BordComputer.java | 21 ++++++++++++++++++++- src/test/java/BordComputerTest.java | 14 +++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/BordComputer.java b/src/main/java/BordComputer.java index 1a0cbf3..e226dd4 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; @@ -45,7 +47,24 @@ public class BordComputer { installedDevices=tempDevices; //setting activeDevice 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; } } diff --git a/src/test/java/BordComputerTest.java b/src/test/java/BordComputerTest.java index 86ab927..91d5d18 100644 --- a/src/test/java/BordComputerTest.java +++ b/src/test/java/BordComputerTest.java @@ -1,4 +1,5 @@ import device.Device; +import device.cdPlayer.CD; import device.cdPlayer.CDPlayer; import device.radioPlayer.RadioPlayer; import device.usbPlayer.USB_Stick; @@ -94,6 +95,8 @@ class BordComputerTest { assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice); }else if (caseNr == 3) { assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull(); + }else if (caseNr == 4) { + assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull(); } } @@ -120,11 +123,20 @@ class BordComputerTest { bc2.setDevices(); m =bc2.changeDevice(); + //forth case + BordComputer bc3 = new BordComputer(); + bc3.readConfig(); + bc3.setDevices(); + m =bc3.changeDevice(); + m =bc3.changeDevice(); //CDPlayer + + 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 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) ); }