Browse Source

Merge commit '0a02c7b9cdea159b75a781abdac4db4ab846240b' into HEAD

feature-pr-changeOrderInSavedPlaylist
Jenkins 3 years ago
parent
commit
159a41d17c
  1. 8
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 21
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -202,4 +202,12 @@ public class RadioPlayer implements Device {
} else return " Last Station: 01 " + station + " can´t by deleted";
}
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!";
}
}

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

@ -244,4 +244,25 @@ class RadioPlayerTest {
Arguments.of("Test for not delete station in saved playlist if this is the last station", rp1, "noDelete", true)
);
}
@ParameterizedTest
@MethodSource("changeToSavedPlaylistOptions")
void testChangeToSavedPlaylist(String testName, RadioPlayer testRp, String expectedResult) {
String savedStation = testRp.playedStation;
assertThat(savedStation).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> changeToSavedPlaylistOptions() {
RadioPlayer rp = new RadioPlayer();
rp.changeToSavedPlaylist();
RadioPlayer rp1 = new RadioPlayer();
rp1.changeRegion("BY");
rp1.changeToSavedPlaylist();
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 in regional playlist", rp1, "YouFM")
);
}
}
Loading…
Cancel
Save