From 28bee40852549f9a279ec0c1f793e344efab2c8a Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 18 Feb 2022 00:06:00 +0100 Subject: [PATCH] UsbPlayerTest.louder_10_Test Forth Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 9 ++++++--- .../java/device/usbPlayer/UsbPlayerTest.java | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 5796406..ea93e00 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -126,10 +126,13 @@ public class UsbPlayer implements Device { } public void Louder_10() { - Lautstaerke += 10; - if (Lautstaerke > 100) { - Lautstaerke = 100; + if(this.soundWas == -1) { + Lautstaerke += 10; + if (Lautstaerke > 100) { + Lautstaerke = 100; + } } + } public void quieter_10() { diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index d94b380..4da5857 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -185,22 +185,29 @@ class UsbPlayerTest { static Stream louder_10_Options() { USB_Stick USBDrive = new USB_Stick(); + //first case UsbPlayer up1 = new UsbPlayer(USBDrive); up1.Louder_10(); - + //Second case UsbPlayer up2 = new UsbPlayer(USBDrive); - for (int i = 0; i <= 3; i++) { + for (int i = 0; i < 3; i++) { up2.Louder_10(); } - up2.quieter_10(); - + //third case UsbPlayer up3 = new UsbPlayer(USBDrive); up3.setLautstaerke(100); up3.Louder_10(); + //forth case + UsbPlayer up4 = new UsbPlayer(USBDrive); + up4.setLautstaerke(10); + up4.mute(); + up4.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) + Arguments.of("Volume was 100, should stay 100 ", up3, 100), + Arguments.of("Volume is muted,no change can be made ", up4, 0) ); }