Browse Source

UsbPlayerTest.quieterTest third Case

feature-pr-USB-otherTests
sahar 3 years ago
parent
commit
21b630ae04
  1. 15
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 13
      src/test/java/device/usbPlayer/UsbPlayerTest.java

15
src/main/java/device/usbPlayer/UsbPlayer.java

@ -12,7 +12,7 @@ public class UsbPlayer implements Device {
private Boolean isConnected;
private Boolean isDefect;
int Lautstaerke = 0;
int soundWas ;
int soundWas =-1;
public USB_Stick USBDrive = new USB_Stick();
@ -104,11 +104,14 @@ public class UsbPlayer implements Device {
//**********search method*************
@Override
public void quieter() {
if (Lautstaerke > 0) {
Lautstaerke -= 1;
} else {
Lautstaerke = 0;
if(this.soundWas == -1){
if (Lautstaerke > 0 ) {
Lautstaerke -= 1;
} else {
Lautstaerke = 0;
}
}
}
@Override
@ -193,7 +196,7 @@ public class UsbPlayer implements Device {
public String unmute() {
setLautstaerke(soundWas);
this.soundWas = 0;
this.soundWas = -1;
return "unmuted";
}

13
src/test/java/device/usbPlayer/UsbPlayerTest.java

@ -79,14 +79,25 @@ class UsbPlayerTest {
static Stream<Arguments> quieterOptions() {
USB_Stick USBDrive = new USB_Stick();
//first case
UsbPlayer up1 = new UsbPlayer(USBDrive);
up1.quieter();
//second case
UsbPlayer up2 = new UsbPlayer(USBDrive);
up2.setLautstaerke(10);
up2.quieter();
//third case
UsbPlayer up3 = new UsbPlayer(USBDrive);
up3.setLautstaerke(10);
up3.mute();
up3.quieter();
return Stream.of(
Arguments.of("Volume must stay 0 ", up1, 0),
Arguments.of("Volume must be 9 ", up2, 9)
Arguments.of("Volume must be 9 ", up2, 9),
Arguments.of("Volume is muted,no change can be made ", up3, 0)
);
}

Loading…
Cancel
Save