Browse Source

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

feature-pr-RadioPlayer-chooseItem
Jan Ortner 3 years ago
parent
commit
820d148f30
  1. 5
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 5
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -158,9 +158,14 @@ public class RadioPlayer implements Device {
@Override
public String chooseItem(int itemNr) {
if(itemNr > savedPlaylist.size()) {
playedStation = savedPlaylist.get(savedPlaylist.size()-1);
return ("Radio is playing station: 0" + savedPlaylist.size() + " " + this.playedStation + " from saved playlist");
}else{
playedStation = savedPlaylist.get(itemNr - 1);
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist");
}
}
@Override
public String[] getItemList() {

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

@ -183,9 +183,12 @@ class RadioPlayerTest {
static Stream<Arguments> chooseItemOptions() {
RadioPlayer rp = new RadioPlayer();
rp.chooseItem(2);
RadioPlayer rp1 = new RadioPlayer();
rp1.chooseItem(5);
return Stream.of(
Arguments.of("Test select station to play with nr isn`t bigger than playlist size", rp, "Teddy")
Arguments.of("Test select station in saved playlist to play with nr isn`t bigger than playlist size", rp, "Teddy"),
Arguments.of("Test select station in saved playlist to play with nr is bigger than playlist size. Last station in playlist gets played", rp1, "MegaHits")
);
}

Loading…
Cancel
Save