From 9c4084e47940870dd0b38e6ad15b0be0b2820bd3 Mon Sep 17 00:00:00 2001 From: JPANZO Date: Thu, 17 Feb 2022 22:49:18 +0100 Subject: [PATCH] Method mute of CDPlayer tested on 6x louder()-> mute() -> getOldVolumeShouldReturn_0. --- src/main/java/device/cdPlayer/CDPlayer.java | 1 + src/test/java/device/cdPlayer/CDPlayerTest.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index b08c602..ca99dfb 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -122,6 +122,7 @@ public class CDPlayer implements Device { public String unmute() { muted=false; volume=oldVolume; + oldVolume=0; return ("Volume unmute."); } diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index 988a878..06cdff8 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -584,13 +584,23 @@ class CDPlayerTest { 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 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 5x louder()-> mute()] => getVolumeShouldReturn_5", "Case3", cdPlayer1, "Volume unmute."), + Arguments.of("[unmute() by 6x louder()-> mute()] => getOldVolumeShouldReturn_0", "Case4", cdPlayer1, "Volume unmute.") ); }