From f683c378d17c68089266971078a75beb935052c8 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 18 Feb 2022 00:10:35 +0100 Subject: [PATCH] UsbPlayerTest.quieter_10_Test Forth Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 8 +++++--- src/test/java/device/usbPlayer/UsbPlayerTest.java | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index ea93e00..034c19d 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -136,9 +136,11 @@ public class UsbPlayer implements Device { } public void quieter_10() { - Lautstaerke -= 10; - if (Lautstaerke < 0) { - Lautstaerke = 0; + if(this.soundWas == -1) { + Lautstaerke -= 10; + if (Lautstaerke < 0) { + Lautstaerke = 0; + } } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 48ffd9c..f222f15 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -240,10 +240,17 @@ class UsbPlayerTest { UsbPlayer up3 = new UsbPlayer(USBDrive); up3.quieter_10(); + //forth case + UsbPlayer up4 = new UsbPlayer(USBDrive); + up4.setLautstaerke(11); + up4.mute(); + up4.quieter_10(); + return Stream.of( Arguments.of("Volume was 10, should be 0 ", up1, 0), Arguments.of("Volume was 50, should be 20 ", up2, 20), - Arguments.of("Volume was 0, should stay 0 ", up3, 0) + Arguments.of("Volume was 0, should stay 0 ", up3, 0), + Arguments.of("Volume is muted,no change can be made ", up4, 0) ); }