Browse Source

added fifth test case for getInfoText() & and added productive code for RadioPlayer

feature-pr-RadioPlayer-getInfoText
Jan Ortner 3 years ago
parent
commit
dd88b2967c
  1. 4
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 6
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -150,8 +150,8 @@ public class RadioPlayer implements Device {
@Override @Override
public String getInfoText() { public String getInfoText() {
String infoText = playedStation; String infoText = playedStation;
if(regionPlaylist.contains(playedStation)) return ("Regional playlist " + infoText);
else return ("Saved playlist " + infoText);
if(regionPlaylist.contains(playedStation)) return ("Regional playlist: " + infoText);
else return ("Saved playlist: "+ (savedPlaylist.indexOf(playedStation) + 1) + infoText);
} }
@Override @Override

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

@ -383,6 +383,7 @@ class RadioPlayerTest {
else if(testTyp.contains("station")) bool = testRp.getInfoText().contains(testRp.playedStation); else if(testTyp.contains("station")) bool = testRp.getInfoText().contains(testRp.playedStation);
else if(testTyp.contains("region")) bool = testRp.getInfoText().contains("Regional playlist"); else if(testTyp.contains("region")) bool = testRp.getInfoText().contains("Regional playlist");
else if(testTyp.contains("saved")) bool = testRp.getInfoText().contains("Saved playlist"); else if(testTyp.contains("saved")) bool = testRp.getInfoText().contains("Saved playlist");
else if(testTyp.contains("savedNum")) bool = testRp.getInfoText().contains(("0") + testRp.savedPlaylist.indexOf(testRp.playedStation) + 1);
assertThat(bool).describedAs(testName).isEqualTo(expectedResult); assertThat(bool).describedAs(testName).isEqualTo(expectedResult);
} }
@ -393,12 +394,15 @@ class RadioPlayerTest {
RadioPlayer rp2 = new RadioPlayer(); RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY"); rp2.changeRegion("BY");
RadioPlayer rp3 = new RadioPlayer(); RadioPlayer rp3 = new RadioPlayer();
RadioPlayer rp4 = new RadioPlayer();
rp4.next();
return Stream.of( return Stream.of(
Arguments.of("Test for getInfoText is not empty or null", "null", rp, false), Arguments.of("Test for getInfoText is not empty or null", "null", rp, false),
Arguments.of("Test for getInfoText contains played station", "station", rp1, true), Arguments.of("Test for getInfoText contains played station", "station", rp1, true),
Arguments.of("Test for getInfoText contains regional playlist if played station is in it", "region", rp2, true), Arguments.of("Test for getInfoText contains regional playlist if played station is in it", "region", rp2, true),
Arguments.of("Test for getInfoText contains saved playlist if played station is in it", "saved", rp3, true)
Arguments.of("Test for getInfoText contains saved playlist if played station is in it", "saved", rp3, true),
Arguments.of("Test for getInfoText contains station number in saved playlist", "savedNum", rp4, true)
); );
} }
} }
Loading…
Cancel
Save