From d87cc79bd02c9e53f54571ee997160800d3bf251 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Mon, 7 Feb 2022 22:52:15 +0100 Subject: [PATCH] revised Test for prev and next and updated functions --- .../device/radioPlayer/RadioPlayerTest.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 1d0549f..a2bd01d 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/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); +} + + static Stream 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 prev() { - rp.prev(); - int currentIndex=rp.Playlist.indexOf(rp.playTrack); - assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); - - } /* + @Test void getInfoText() { }