Browse Source

added second test case for changeToSavedPlaylist() & and added productive code

feature-pr-changeToSavedPlaylist
Jan Ortner 3 years ago
parent
commit
0a02c7b9cd
  1. 5
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 6
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -203,6 +203,11 @@ public class RadioPlayer implements Device {
} }
public String changeToSavedPlaylist() { public String changeToSavedPlaylist() {
if(regionPlaylist.contains(playedStation)) {
playedStation = savedPlaylist.get(0);
regionPlaylist.clear();
return "Playlist switched now playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist";
}
return "You are already in saved Playlist!"; return "You are already in saved Playlist!";
} }
} }

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

@ -255,9 +255,13 @@ class RadioPlayerTest {
static Stream<Arguments> changeToSavedPlaylistOptions() { static Stream<Arguments> changeToSavedPlaylistOptions() {
RadioPlayer rp = new RadioPlayer(); RadioPlayer rp = new RadioPlayer();
rp.changeToSavedPlaylist(); rp.changeToSavedPlaylist();
RadioPlayer rp1 = new RadioPlayer();
rp1.changeRegion("BY");
rp1.changeToSavedPlaylist();
return Stream.of( return Stream.of(
Arguments.of("Test for change to saved playlist when you already in saved playlist", rp, "YouFM")
Arguments.of("Test for change to saved playlist when you already in saved playlist", rp, "YouFM"),
Arguments.of("Test for change to saved playlist when in regional playlist", rp1, "YouFM")
); );
} }
Loading…
Cancel
Save