From 559b156bd51908b15ad8ccd3fb97416d187bdc96 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 22:21:50 +0100 Subject: [PATCH] UsbPlayerTest.quieter_10_Test second Case --- .../java/device/usbPlayer/UsbPlayerTest.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 03e1a50..737bf15 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -136,7 +136,32 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("louder_10_Options") + void louder_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream louder_10_Options() { + UsbPlayer up1 = new UsbPlayer(); + up1.Louder_10(); + + UsbPlayer up2 = new UsbPlayer(); + for (int i = 0; i <= 3; i++) { + up2.Louder_10(); + } + up2.quieter_10(); + UsbPlayer up3 = new UsbPlayer(); + up3.setLautstaerke(100); + up3.Louder_10(); + return Stream.of( + Arguments.of("Volume was 0, should be 10 ", up1, 10), + Arguments.of("Volume was 0, should be 30 ", up2, 30), + Arguments.of("Volume was 100, should stay 100 ", up3, 100) + ); + } @ParameterizedTest @MethodSource("quieter_10_Options") void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { @@ -149,8 +174,16 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { up1.setLautstaerke(10); up1.quieter_10(); + UsbPlayer up2 = new UsbPlayer(); + up2.setLautstaerke(50); + for (int i = 0; i < 3; i++) { + up2.quieter_10(); + } + + return Stream.of( - Arguments.of("Volume was 10, should be 0 ", up1, 0) + Arguments.of("Volume was 10, should be 0 ", up1, 0), + Arguments.of("Volume was 50, should be 20 ", up2, 20) ); }