From 3d34b2c239cb88c4a839866359dc3ae508468c08 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 22:25:23 +0100 Subject: [PATCH] UsbPlayerTest.quieter_10_Test third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 3 +++ src/test/java/device/usbPlayer/UsbPlayerTest.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index c2f51f7..dadba47 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -113,6 +113,9 @@ public class UsbPlayer implements Device { public void quieter_10(){ Lautstaerke -= 10; + if (Lautstaerke < 0) { + Lautstaerke = 0; + } } @Override diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 737bf15..03c5b2c 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -180,10 +180,13 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { up2.quieter_10(); } + UsbPlayer up3 = new UsbPlayer(); + up3.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 50, should be 20 ", up2, 20), + Arguments.of("Volume was 0, should stay 0 ", up3, 0) ); }