Browse Source

added first test case for changeOrderInSavedPlaylist() & and added productive code

feature-pr-changeOrderInSavedPlaylist
Jan Ortner 3 years ago
parent
commit
799360763a
  1. 7
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 17
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -210,4 +210,11 @@ public class RadioPlayer implements Device {
}
return "You are already in saved Playlist!";
}
public String changeOrderInSavedPlaylist(int nr) {
String station = playedStation;
savedPlaylist.remove(playedStation);
savedPlaylist.add(nr-1,station);
return"Station " + playedStation + " is now on place 0" + nr + "in saved playlist";
}
}

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

@ -265,4 +265,21 @@ class RadioPlayerTest {
);
}
@ParameterizedTest
@MethodSource("changeOrderInSavedPlaylistOptions")
void testChangeOrderInSavedPlaylist(String testName, RadioPlayer testRp, int nr, String expectedResult) {
String savedStation = testRp.savedPlaylist.get(nr);
assertThat(savedStation).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> changeOrderInSavedPlaylistOptions() {
RadioPlayer rp = new RadioPlayer();
rp.next();
rp.changeOrderInSavedPlaylist(1);
return Stream.of(
Arguments.of("Test for change order in saved playlist with nr isn`t than playlist size", rp, 0, "Teddy")
);
}
}
Loading…
Cancel
Save