Browse Source

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

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

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

@ -158,7 +158,8 @@ public class RadioPlayer implements Device {
@Override
public String chooseItem(int itemNr) {
return null;
playedStation = savedPlaylist.get(itemNr - 1);
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist");
}
@Override

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

@ -171,11 +171,24 @@ class RadioPlayerTest {
@Test
void getOptions() {
}
*/
@Test
void chooseOption() {
@ParameterizedTest
@MethodSource("chooseItemOptions")
void testChooseItem(String testName, RadioPlayer testRp, String expectedResult) {
String playedStation = testRp.playedStation;
assertThat(playedStation).describedAs(testName).isEqualTo(expectedResult);
}
*/
static Stream<Arguments> chooseItemOptions() {
RadioPlayer rp = new RadioPlayer();
rp.chooseItem(2);
return Stream.of(
Arguments.of("Test select station to play with nr isn`t bigger than playlist size", rp, "Teddy")
);
}
@ParameterizedTest
@MethodSource("testPlayOptions")
void testPlay(String testName, RadioPlayer testRp, String expectedResult) {

Loading…
Cancel
Save