From 802a780a4eaaf01459b8656862b8c43ccc453302 Mon Sep 17 00:00:00 2001 From: sahar Date: Thu, 17 Feb 2022 21:20:49 +0100 Subject: [PATCH] UsbPlayerTest.muteTest Second Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 8 ++++-- .../java/device/usbPlayer/UsbPlayerTest.java | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 7e862b5..0b7a255 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -12,6 +12,8 @@ public class UsbPlayer implements Device { private Boolean isConnected; private Boolean isDefect; int Lautstaerke = 0; + int soundWas ; + public USB_Stick USBDrive = new USB_Stick(); public ArrayList getPlaylist() { @@ -134,7 +136,7 @@ public class UsbPlayer implements Device { @Override public int getVolume() { - return 0; + return Lautstaerke; } @Override @@ -182,7 +184,9 @@ public class UsbPlayer implements Device { @Override public String mute() { - return null; + + setLautstaerke(0); + return "muted"; } @Override diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 92688cd..3663731 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -429,6 +429,31 @@ class UsbPlayerTest { Arguments.of("USB Player with Albums ", up1,"USB Player is on : "+up1.getPlayTrack()), Arguments.of("USB Player with no Albums ", up2,"USB Player with no Albums") ); + }//"muted" + + @ParameterizedTest + @MethodSource("muteOptions") + void muteTest(String testName, UsbPlayer inputUSB, String expectedResult,String testName2) { + + String isMuted = inputUSB.mute(); + assertThat(isMuted).describedAs(testName).isEqualTo(expectedResult); + //Second case + assertThat(inputUSB.getLautstaerke()).describedAs(testName2).isEqualTo(0); + + } + + static Stream muteOptions() { + USB_Stick USBDrive = new USB_Stick(); + + //first case + UsbPlayer up1 = new UsbPlayer(USBDrive); + up1.mute(); + + + return Stream.of( + Arguments.of("The Sound is muted ", up1,"muted","Sound level is 0") + + ); } } \ No newline at end of file