Browse Source

revised Test for prev and next and updated functions

feature-dev-revise_rp_nextprev
alpina0707 3 years ago
parent
commit
d87cc79bd0
  1. 38
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -2,7 +2,13 @@ package device.radioPlayer;
import device.radioPlayer.RadioPlayer;
import device.usbPlayer.UsbPlayer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
@ -43,22 +49,30 @@ class RadioPlayerTest {
void getVolume() {
}
*/
@Test
void next() {
rp.next();
int currentIndex=rp.Playlist.indexOf(rp.playTrack);
assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size()));
@ParameterizedTest
@MethodSource("prevNextOptions")
void prevNextTest(String testName, RadioPlayer testRp, String expectedResult) {
String station = testRp.playTrack;
assertThat(station).describedAs(testName).isEqualTo(expectedResult);
}
@Test
void prev() {
rp.prev();
int currentIndex=rp.Playlist.indexOf(rp.playTrack);
assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size()));
static Stream<Arguments> prevNextOptions() {
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
RadioPlayer rp3 = new RadioPlayer();
rp1.next();
rp2.next();
rp2.prev();
rp3.prev();
return Stream.of(
Arguments.of("Next Station Test", rp1, "Radio Teddy"),
Arguments.of("Prev Station Test", rp2, "Radio YouFM"),
Arguments.of("Prev works on first Station ", rp3, "Radio MegaHits")
);
}
/*
@Test
void getInfoText() {
}

Loading…
Cancel
Save