Browse Source

added second test case for getItemList() & and added productive code for RadioPlayer

feature-pr-RadioPlayer-getItemList
Jan Ortner 3 years ago
parent
commit
b7b79badda
  1. 5
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 12
      src/test/java/device/radioPlayer/RadioPlayerTest.java

5
src/main/java/device/radioPlayer/RadioPlayer.java

@ -185,7 +185,10 @@ public class RadioPlayer implements Device {
@Override
public String[] getItemList() {
return savedPlaylist.toArray(new String[0]);
if (regionPlaylist.contains(playedStation))
return regionPlaylist.toArray(new String[0]);
else
return savedPlaylist.toArray(new String[0]);
}
@Override

12
src/test/java/device/radioPlayer/RadioPlayerTest.java

@ -320,18 +320,26 @@ class RadioPlayerTest {
Arguments.of("Test for change order in saved playlist with nr is than smaller than 0 at front of playlist", rp2, 0, "Teddy")
);
}
@ParameterizedTest
@MethodSource("getItemListOptions")
void testGetItemList(String testName, RadioPlayer testRp, String[] expectedResult) {
void testGetItemList(String testName, RadioPlayer testRp, String testTyp, String[] expectedResult) {
if (testTyp.equals("region")) {
testRp.changeRegion("BY");
}
String[] playList = testRp.getItemList();
assertThat(playList).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> getItemListOptions() {
RadioPlayer rp = new RadioPlayer();
RadioPlayer rp1 = new RadioPlayer();
rp1.changeRegion("BY");
return Stream.of(
Arguments.of("Test for return saved playlist", rp, rp.savedPlaylist.toArray(new String[0]))
Arguments.of("Test for return saved playlist", rp, "saved", rp.savedPlaylist.toArray(new String[0])),
Arguments.of("Test for return regional playlist", rp1, "region", rp1.regionPlaylist.toArray(new String[0]))
);
}
}
Loading…
Cancel
Save