From aac9081276a160387e0e2679db6091058976e5db Mon Sep 17 00:00:00 2001 From: sahar Date: Thu, 17 Feb 2022 23:41:27 +0100 Subject: [PATCH] UsbPlayerTest.louderTest third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 10 ++++++---- src/test/java/device/usbPlayer/UsbPlayerTest.java | 13 ++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index c9e15c2..5796406 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -116,10 +116,12 @@ public class UsbPlayer implements Device { @Override public void louder() { - if (Lautstaerke < 100) { - Lautstaerke += 1; - } else { - Lautstaerke = 100; + if(this.soundWas == -1) { + if (Lautstaerke < 100) { + Lautstaerke += 1; + } else { + Lautstaerke = 100; + } } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 202aef3..1bc8d55 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -59,14 +59,25 @@ class UsbPlayerTest { static Stream louderOptions() { USB_Stick USBDrive = new USB_Stick(); + //first case UsbPlayer up11 = new UsbPlayer(USBDrive); up11.louder(); + //second case UsbPlayer up22 = new UsbPlayer(USBDrive); up22.setLautstaerke(100); up22.louder(); + //third case + UsbPlayer up3 = new UsbPlayer(USBDrive); + up3.setLautstaerke(100); + up3.mute(); + up3.louder(); + + + return Stream.of( Arguments.of("Volume is : 1 ", up11, 1), - Arguments.of("Volume is : 100 ", up22, 100) + Arguments.of("Volume is : 100 ", up22, 100), + Arguments.of("Volume is muted,no change can be made ", up3, 0) ); }