From ec0d64d1ea5f3941f80821d0e67cf7c8fcb0c9c2 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 8 Feb 2022 21:01:07 +0100 Subject: [PATCH 1/2] playTest update --- .../java/device/usbPlayer/UsbPlayerTest.java | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 9671e73..12f199d 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -21,19 +21,7 @@ class UsbPlayerTest { UsbPlayer up = new UsbPlayer(); - @Test - void louder_test() { - up.setLautstaerke(40); - up.louder(); - assertThat(up.getLautstaerke()).isEqualTo(41); - } - @Test - void quieter_test() { - up.setLautstaerke(40); - up.quieter(); - assertThat(up.getLautstaerke()).isEqualTo(39); - } /* @Test void getVolume() { @@ -92,7 +80,8 @@ class UsbPlayerTest { 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.") + Arguments.of("not connected : ", up7, "not connected.")); + } @ParameterizedTest @@ -103,15 +92,15 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { } static Stream louderOptions() { - UsbPlayer up1 = new UsbPlayer(); - up1.louder(); - UsbPlayer up2 = new UsbPlayer(); - up2.setLautstaerke(100); - up2.louder(); + UsbPlayer up11 = new UsbPlayer(); + up11.louder(); + UsbPlayer up22 = new UsbPlayer(); + up22.setLautstaerke(100); + up22.louder(); return Stream.of( - Arguments.of("Volume is : 1 ", up1, 1), - Arguments.of("Volume is : 100 ", up2, 100) + Arguments.of("Volume is : 1 ", up11, 1), + Arguments.of("Volume is : 100 ", up22, 100) ); } - */ + } \ No newline at end of file From 1e4cf020e4134ff70b48f51a2991e0e5caa80758 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 8 Feb 2022 21:07:55 +0100 Subject: [PATCH 2/2] playTest , louderTest and quieterTest update --- .../java/device/usbPlayer/UsbPlayerTest.java | 55 +++++++------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 12f199d..bd85948 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -1,52 +1,17 @@ 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.stream.Stream; -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; class UsbPlayerTest { UsbPlayer up = new UsbPlayer(); - - -/* - @Test - void getVolume() { - } - - @Test - void next() { - } - - @Test - void prev() { - } - - @Test - void getInfoText() { - } - - @Test - void getOptions() { - } - - @Test - void chooseOption() { - }*/ - @ParameterizedTest @MethodSource("PlayOptions") void playTest(String testName, UsbPlayer inputPlay, String expectedResult) { @@ -54,7 +19,6 @@ class UsbPlayerTest { assertThat(playState).describedAs(testName).isEqualTo(expectedResult); } - static Stream PlayOptions() { UsbPlayer up1 = new UsbPlayer(); UsbPlayer up8 = new UsbPlayer(); @@ -103,4 +67,23 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("quieterOptions") + void quieterTest(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream quieterOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.quieter(); + UsbPlayer up2 = new UsbPlayer(); + up2.setLautstaerke(10); + up2.quieter(); + return Stream.of( + Arguments.of("Volume must stay 0 ", up1, 0), + Arguments.of("Volume must be 9 ", up2, 9) + ); + } + } \ No newline at end of file