Browse Source

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

feature-pr-RadioPlayer-chooseItem
Jan Ortner 3 years ago
parent
commit
419699e4bc
  1. 3
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 6
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -162,6 +162,9 @@ public class RadioPlayer implements Device {
if (itemNr > regionPlaylist.size()) {
playedStation = regionPlaylist.get(regionPlaylist.size() - 1);
return ("Radio is playing station: 0" + regionPlaylist.size() + " " + this.playedStation + " from regional playlist");
} else if (itemNr < 1) {
playedStation = regionPlaylist.get(0);
return ("Radio is playing station: 01 " + this.playedStation + " from regional playlist");
} else {
playedStation = regionPlaylist.get(itemNr - 1);
return ("Radio is playing station: 0" + (regionPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from regional playlist");

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

@ -193,13 +193,17 @@ class RadioPlayerTest {
RadioPlayer rp4 = new RadioPlayer();
rp4.changeRegion("BY");
rp4.chooseItem(5);
RadioPlayer rp5 = new RadioPlayer();
rp5.changeRegion("BY");
rp5.chooseItem(-2);
return Stream.of(
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"),
Arguments.of("Test select station in saved playlist to play with nr is lower than 0. First station in playlist gets played", rp2, "YouFM"),
Arguments.of("Test select station in regional playlist to play with nr isn`t bigger than playlist size", rp3, "Bayern 1"),
Arguments.of("Test select station in regional playlist to play with nr is bigger than playlist size. Last station in playlist gets played", rp4, "Hit Radio N1")
Arguments.of("Test select station in regional playlist to play with nr is bigger than playlist size. Last station in playlist gets played", rp4, "Hit Radio N1"),
Arguments.of("Test select station in regional playlist to play with nr is lower than 0. Last station in playlist gets played", rp5, "Antenne Bayern")
);
}

Loading…
Cancel
Save