Browse Source

UsbPlayerTest.chooseItemTest First Case

feature-pr-USB-otherTests
sahar 3 years ago
parent
commit
2b0475f00c
  1. 11
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 17
      src/test/java/device/usbPlayer/UsbPlayerTest.java

11
src/main/java/device/usbPlayer/UsbPlayer.java

@ -171,8 +171,7 @@ public class UsbPlayer implements Device {
String InfoText = ""; String InfoText = "";
if (isAllAudio()) { if (isAllAudio()) {
InfoText = "USB Player is on : " + this.getPlayTrack(); InfoText = "USB Player is on : " + this.getPlayTrack();
}
else
} else
InfoText = "USB Player with no Albums"; InfoText = "USB Player with no Albums";
return InfoText; return InfoText;
} }
@ -184,8 +183,14 @@ public class UsbPlayer implements Device {
@Override @Override
public String chooseItem(int itemNr) { public String chooseItem(int itemNr) {
return null;
String songName="";
if (itemNr < this.getPlaylist().size()) {
songName= this.getPlaylist().get(itemNr ).toString();
} }
return songName;
}
@Override @Override
public String[] getItemList() { public String[] getItemList() {

17
src/test/java/device/usbPlayer/UsbPlayerTest.java

@ -542,6 +542,23 @@ class UsbPlayerTest {
Arguments.of("The Sound is unmuted ", up1,"unmuted","Sound level has changed","previous sound level is 0") Arguments.of("The Sound is unmuted ", up1,"unmuted","Sound level has changed","previous sound level is 0")
); );
}//chooseItem
@ParameterizedTest
@MethodSource("chooseItem")
void chooseItemTest(String testName, String inputSong, String expectedResult) {
//int volumeNum = inputPlay.getLautstaerke();
assertThat(inputSong).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> chooseItem() {
USB_Stick USBDrive = new USB_Stick();
//first case
UsbPlayer up1 = new UsbPlayer(USBDrive);
return Stream.of(
Arguments.of("An Item from the Album was chosen ", up1.chooseItem(0), "Musik 01.mp3")
);
} }
} }
Loading…
Cancel
Save