|
|
@ -493,7 +493,7 @@ class CDPlayerTest { |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("addToFavoriteSongsData") |
|
|
|
void addToFavoriteSongs(String testName,String cases, CDPlayer _cdPlayer,Exception exception) { |
|
|
|
void addToFavoriteSongsTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception) { |
|
|
|
if(cases.equals("Case1")) { |
|
|
|
String myFavoriteSong = _cdPlayer.getCD().getPlayList()[0]; |
|
|
|
_cdPlayer.addToFavoriteSongs(myFavoriteSong); |
|
|
@ -531,4 +531,78 @@ class CDPlayerTest { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("muteTestData") |
|
|
|
void muteTest(String testName,String cases, CDPlayer _cdPlayer,String 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); |
|
|
|
} |
|
|
|
if(cases.equals("Case3")) { |
|
|
|
_cdPlayer.louder(); |
|
|
|
_cdPlayer.louder(); |
|
|
|
_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 5x louder() by checkingTheSavedOldVolume] => getOldVolumeShouldReturns_5", "Case4", cdPlayer1, "Volume muted.") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("unmuteTestData") |
|
|
|
void unmuteTest(String testName,String cases, CDPlayer _cdPlayer,String expectedResult) { |
|
|
|
if(cases.equals("Case1")) { |
|
|
|
assertThat(_cdPlayer.unmute()).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
if(cases.equals("Case2")) { |
|
|
|
_cdPlayer.unmute(); |
|
|
|
assertThat(_cdPlayer.isMuted()).describedAs(testName).isEqualTo(false); |
|
|
|
} |
|
|
|
if(cases.equals("Case3")) { |
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
_cdPlayer.louder(); |
|
|
|
} |
|
|
|
_cdPlayer.mute(); |
|
|
|
_cdPlayer.unmute(); |
|
|
|
assertThat(_cdPlayer.isMuted()).describedAs(testName).isEqualTo(false); |
|
|
|
assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(5); |
|
|
|
} |
|
|
|
if(cases.equals("Case4")) { |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
_cdPlayer.louder(); |
|
|
|
} |
|
|
|
_cdPlayer.mute(); |
|
|
|
_cdPlayer.unmute(); |
|
|
|
assertThat(_cdPlayer.isMuted()).describedAs(testName).isEqualTo(false); |
|
|
|
assertThat(_cdPlayer.getOldVolume()).describedAs(testName).isEqualTo(0); |
|
|
|
} |
|
|
|
} |
|
|
|
static Stream<Arguments> unmuteTestData () { |
|
|
|
CDPlayer cdPlayer1 = new CDPlayer(); |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("[unmute() by checkingTheReturnValue ] => ShouldReturnAString", "Case1", cdPlayer1, "Volume unmute."), |
|
|
|
Arguments.of("[unmute() by checkingTheEffectAfterRun ] => VariableMutedShouldBeFalse", "Case2", cdPlayer1, "Volume unmute."), |
|
|
|
Arguments.of("[unmute() by 5x louder()-> mute()] => getVolumeShouldReturn_5", "Case3", cdPlayer1, "Volume unmute."), |
|
|
|
Arguments.of("[unmute() by 6x louder()-> mute()] => getOldVolumeShouldReturn_0", "Case4", cdPlayer1, "Volume unmute.") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |