From b33efc27fd99af3424973fb9d52472c4706b962f Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 19:47:29 +0100 Subject: [PATCH] playTest adding and committing --- .../java/device/usbPlayer/UsbPlayerTest.java | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index bf170fe..574d556 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -1,6 +1,12 @@ package device.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.ArrayList; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; @@ -46,10 +52,41 @@ class UsbPlayerTest { @Test void chooseOption() { + }*/ + + @ParameterizedTest + @MethodSource("PlayOptions") + void playTest(String testName, UsbPlayer inputPlay, String expectedResult) { + String playState = inputPlay.play(); + assertThat(playState).describedAs(testName).isEqualTo(expectedResult); } - @Test - void play() { + static Stream PlayOptions() { + UsbPlayer up1 = new UsbPlayer(); + UsbPlayer up8 = new UsbPlayer(); + up8.setPlayTrack(""); + UsbPlayer up2 = new UsbPlayer(); + ArrayList l = new ArrayList(); + l.add("a.mp3"); + l.add("b.mp3"); + l.add("c.gif"); + up2.setPlaylist(l); + UsbPlayer up3 = new UsbPlayer(); + ArrayList Pl = new ArrayList(); + up3.setPlaylist(Pl); + UsbPlayer up6 = new UsbPlayer(); + up6.setDefect(true); + UsbPlayer up7 = new UsbPlayer(); + up7.setConnected(false); + + + return Stream.of( + Arguments.of("All right : ", up1, "USB : connected,working,have a list,Audio,point to a track."), + Arguments.of("No first Track : ", up8, "USB : connected,working,have a list,Audio,doesn't point to a track."), + Arguments.of("No Audio Files : ", up2, "USB : connected,working,have a list,not Audio."), + Arguments.of("No list of tracks : ", up3, "USB : connected,working,have no list."), + Arguments.of("connected , not working : ", up6, "USB : connected,not working."), + Arguments.of("not connected : ", up7, "not connected.") + ); } - */ } \ No newline at end of file