Browse Source

Method mute of CDPlayer tested on checkingTheEffectAfterRun -> VariableMutedShouldBeTrue.

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

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

@ -25,6 +25,8 @@ public class CDPlayer implements Device {
private List<String>favoriteSongs=new ArrayList<>();
private boolean muted=false;
@Override
public void louder() {
if(volume < 100) {
@ -109,6 +111,7 @@ public class CDPlayer implements Device {
@Override
public String mute() {
muted=true;
return ("Volume muted.");
}
@ -229,4 +232,8 @@ public class CDPlayer implements Device {
public List<String> getFavoriteSongs() {
return favoriteSongs;
}
public boolean isMuted() {
return muted;
}
}

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

@ -534,12 +534,19 @@ class CDPlayerTest {
@ParameterizedTest
@MethodSource("muteTestData")
void muteTest(String testName,String cases, CDPlayer _cdPlayer,String expectedResult) {
assertThat(_cdPlayer.mute()).describedAs(testName).isEqualTo(expectedResult);
if(cases.equals("Case1")) {
assertThat(_cdPlayer.mute()).describedAs(testName).isEqualTo(expectedResult);
}
if(cases.equals("Case2")) {
_cdPlayer.mute();
assertThat(_cdPlayer.isMuted()).describedAs(testName).isEqualTo(true);
}
}
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 checkingTheReturnValue ] => ShouldReturnAString", "Case1", cdPlayer1, "Volume muted."),
Arguments.of("[mute() by checkingTheEffectAfterRun ] => VariableMutedShouldBeTrue", "Case2", cdPlayer1, "Volume muted.")
);
}

Loading…
Cancel
Save