Browse Source

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

feature-pr-RadioPlayer-getInfoText
Jan Ortner 3 years ago
parent
commit
57114df69a
  1. 2
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 17
      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 null;
return "InfoText";
} }
@Override @Override

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

@ -1,6 +1,7 @@
package device.radioPlayer; package device.radioPlayer;
import org.assertj.core.util.Strings;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
@ -373,4 +374,20 @@ class RadioPlayerTest {
rp.unmute(); rp.unmute();
assertThat(rp.getVolume()).describedAs("Test if unmute is setting the saved volume").isEqualTo(rp.savedVolume); assertThat(rp.getVolume()).describedAs("Test if unmute is setting the saved volume").isEqualTo(rp.savedVolume);
} }
@ParameterizedTest
@MethodSource("getInfoTextOptions")
void testGetInfoText(String testName, RadioPlayer testRp, boolean expectedResult) {
Boolean volume = Strings.isNullOrEmpty(testRp.getInfoText());
assertThat(volume).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> getInfoTextOptions() {
RadioPlayer rp = new RadioPlayer();
return Stream.of(
Arguments.of("Test for getInfoText is not empty or null", rp, false)
);
}
} }
Loading…
Cancel
Save