Browse Source

Method mute of CDPlayer tested after 5x louder() by checkingTheSavedOldVolume -> getOldVolumeShouldReturns_5.

feature-pr-jacksonsNewFeature
JPANZO 3 years ago
parent
commit
9d7abe2b43
  1. 7
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 10
      src/test/java/device/cdPlayer/CDPlayerTest.java

7
src/main/java/device/cdPlayer/CDPlayer.java

@ -26,6 +26,7 @@ public class CDPlayer implements Device {
private List<String>favoriteSongs=new ArrayList<>();
private boolean muted=false;
private int oldVolume=0;
@Override
public void louder() {
@ -112,6 +113,7 @@ public class CDPlayer implements Device {
@Override
public String mute() {
muted=true;
oldVolume=volume;
volume=0;
return ("Volume muted.");
}
@ -237,4 +239,9 @@ public class CDPlayer implements Device {
public boolean isMuted() {
return muted;
}
public int getOldVolume() {
return oldVolume;
}
}

10
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -547,13 +547,21 @@ class CDPlayerTest {
_cdPlayer.mute();
assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(0);
}
if(cases.equals("Case4")) {
for (int i = 0; i < 5; i++) {
_cdPlayer.louder();
}
_cdPlayer.mute();
assertThat(_cdPlayer.getOldVolume()).describedAs(testName).isEqualTo(5);
}
}
static Stream<Arguments> muteTestData () {
CDPlayer cdPlayer1 = new CDPlayer();
return Stream.of(
Arguments.of("[mute() by checkingTheReturnValue ] => ShouldReturnAString", "Case1", cdPlayer1, "Volume muted."),
Arguments.of("[mute() by checkingTheEffectAfterRun ] => VariableMutedShouldBeTrue", "Case2", cdPlayer1, "Volume muted."),
Arguments.of("[mute() after 2x louder() by checkingTheVolume] => VolumeShouldBeSetTo0", "Case3", cdPlayer1, "Volume muted.")
Arguments.of("[mute() after 2x louder() by checkingTheVolume] => VolumeShouldBeSetTo0", "Case3", cdPlayer1, "Volume muted."),
Arguments.of("[mute() after 5x louder() by checkingTheSavedOldVolume] => getOldVolumeShouldReturns_5", "Case4", cdPlayer1, "Volume muted.")
);
}

Loading…
Cancel
Save