Browse Source

added new test case for play() & changed play() to show if playedStation is in regional or saved playlist

feature-pr-playAddedRegionIndicator
Jan Ortner 3 years ago
parent
commit
492cbdb790
  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

@ -164,7 +164,10 @@ public class RadioPlayer implements Device {
@Override @Override
public String play() { public String play() {
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation);
if (regionPlaylist.contains(playedStation))
return ("Radio is playing station: 0" + (regionPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from regional playlist");
else
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist");
} }
public String showStationInfo() { public String showStationInfo() {

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

@ -185,9 +185,12 @@ class RadioPlayerTest {
static Stream<Arguments> testPlayOptions() { static Stream<Arguments> testPlayOptions() {
RadioPlayer rp1 = new RadioPlayer(); RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY");
return Stream.of( return Stream.of(
Arguments.of("Test for playing first station on saved playlist", rp1, "Radio is playing station: 01 YouFM")
Arguments.of("Test for playing first station on saved playlist", rp1, "Radio is playing station: 01 YouFM from saved playlist"),
Arguments.of("Test for playing first station on regional playlist", rp2, "Radio is playing station: 01 Antenne Bayern from regional playlist")
); );
} }

Loading…
Cancel
Save