Browse Source

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

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

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

@ -149,7 +149,7 @@ public class RadioPlayer implements Device {
@Override @Override
public String getInfoText() { public String getInfoText() {
return "InfoText";
return playedStation;
} }
@Override @Override

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

@ -377,17 +377,21 @@ class RadioPlayerTest {
@ParameterizedTest @ParameterizedTest
@MethodSource("getInfoTextOptions") @MethodSource("getInfoTextOptions")
void testGetInfoText(String testName, RadioPlayer testRp, boolean expectedResult) {
Boolean volume = Strings.isNullOrEmpty(testRp.getInfoText());
void testGetInfoText(String testName, String testTyp, RadioPlayer testRp, boolean expectedResult) {
Boolean bool;
if(testTyp.equals("null")) bool = Strings.isNullOrEmpty(testRp.getInfoText());
else bool = testRp.getInfoText().contains(testRp.playedStation);
assertThat(volume).describedAs(testName).isEqualTo(expectedResult);
assertThat(bool).describedAs(testName).isEqualTo(expectedResult);
} }
static Stream<Arguments> getInfoTextOptions() { static Stream<Arguments> getInfoTextOptions() {
RadioPlayer rp = new RadioPlayer(); RadioPlayer rp = new RadioPlayer();
RadioPlayer rp1 = new RadioPlayer();
return Stream.of( return Stream.of(
Arguments.of("Test for getInfoText is not empty or 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)
); );
} }
} }
Loading…
Cancel
Save