Browse Source

UsbPlayerTest.getItemList First Case

feature-pr-USB-otherTests
sahar 3 years ago
parent
commit
32693bf8fa
  1. 6
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 23
      src/test/java/device/usbPlayer/UsbPlayerTest.java

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

@ -196,7 +196,11 @@ public class UsbPlayer implements Device {
@Override
public String[] getItemList() {
return null;
String array[] = new String[getPlaylist().size()];
for(int j =0;j<getPlaylist().size();j++){
array[j] = getPlaylist().get(j);
}
return array;
}
@Override

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

@ -9,6 +9,7 @@ import java.util.ArrayList;
import static org.assertj.core.api.Assertions.assertThat;
class UsbPlayerTest {
//UsbPlayer up = new UsbPlayer();
@ -542,12 +543,11 @@ class UsbPlayerTest {
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);
}
@ -560,6 +560,25 @@ class UsbPlayerTest {
Arguments.of("Incorrect Nr of Item was given < 0", up1.chooseItem(-1), "The Nr is smaller than 0"),
Arguments.of("Incorrect Nr of Item was given > 0", up1.chooseItem(5), "The Nr is bigger than 0")
);
}//getItemList
@ParameterizedTest
@MethodSource("getItemList")
void getItemListTest(String testName, UsbPlayer inputPlayer, String[] expectedResult) {
String[] Pl = inputPlayer.getItemList();
assertThat(Pl).contains("Musik 01.mp3","Musik 02.mp3","Musik 03.mp3").describedAs(testName);
}
static Stream<Arguments> getItemList() {
USB_Stick USBDrive = new USB_Stick();
UsbPlayer up1 = new UsbPlayer(USBDrive);
String[] Pl = {"Musik 01.mp3","Musik 02.mp3","Musik 03.mp3"};
return Stream.of(
Arguments.of("An Album was returned ", up1, Pl,1)
);
}
}
Loading…
Cancel
Save