From 35663bd953cea50d16555ec7ebbad30ad326545a Mon Sep 17 00:00:00 2001 From: JPANZO Date: Tue, 8 Feb 2022 21:31:37 +0100 Subject: [PATCH] CDPlayer-Methods[play,louder,quieter] update. --- .../java/device/cdPlayer/CDPlayerTest.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index 7126d3e..91ef68a 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -1,7 +1,6 @@ package device.cdPlayer; import device.cdPlayer.exceptions.*; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -121,5 +120,37 @@ class CDPlayerTest { ); } + @ParameterizedTest + @MethodSource("quieterTestData") + void quieterTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, int expectedResult) { + for (int i = 0; i < anzClicks; i++) { + _cdPlayer.quieter(); + } + + if(testDirection.equals("VolumeDecreased")){ + for (int i = 0; i < 20; i++) { + _cdPlayer.louder(); + } + for (int i = 0; i < anzClicks; i++) { + _cdPlayer.quieter(); + } + assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(expectedResult); + } + if(testDirection.equals("VolumeHasNotChanged")){ + assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(expectedResult); + }if(testDirection.equals("VolumeNotIncreased")){ + + assertThat(_cdPlayer.getVolume()).describedAs(testName).isNotEqualTo(expectedResult); + } + } + + static Stream quieterTestData () { + CDPlayer cdPlayer=new CDPlayer(); + return Stream.of( + Arguments.of("[getVolume() after 20x quieter() starting by 20] => VolumeHasDecreased","VolumeDecreased", cdPlayer, 19, 1), + Arguments.of("[getVolume() after 20x quieter() starting by 0] => VolumeHasNotChanged","VolumeHasNotChanged" ,cdPlayer,20,0), + Arguments.of("[getVolume() after 5x quieter() starting by 0] => VolumeNotIncreased","VolumeNotIncreased", cdPlayer,5,5) + ); + } } \ No newline at end of file