From 05de803468e0e049f568b8fe1a87632c4ce83e28 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Wed, 9 Feb 2022 18:50:05 +0100 Subject: [PATCH] implemented basic louder function for one step louder --- .../java/device/radioPlayer/RadioPlayer.java | 12 ++---------- .../device/radioPlayer/RadioPlayerTest.java | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index e2cc7d1..f3b6b04 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -29,20 +29,12 @@ public class RadioPlayer implements Device { @Override public void louder() { - if(Lautstaerke < 100) { - Lautstaerke += 1; - } else { - Lautstaerke = 100; - } + Lautstaerke+=1; } @Override public void quieter() { - if(Lautstaerke > 0) { - Lautstaerke -= 1; - } else { - Lautstaerke = 0; - } + } @Override public int getVolume() { diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 3f2c716..e261242 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -16,7 +16,23 @@ class RadioPlayerTest { RadioPlayer rp = new RadioPlayer(); + @ParameterizedTest + @MethodSource("quieterLouderOptions") + void quieterLouderTest(String testName, RadioPlayer testRp, int expectedResult) { + int volume = testRp.getLautstaerke(); + assertThat(volume).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream quieterLouderOptions() { + RadioPlayer rp1 = new RadioPlayer(); + rp1.setLautstaerke(0); + rp1.louder(); + return Stream.of( + Arguments.of("Test for one louder", rp1, 1) + ); + } +/* @Test void louder() { rp.setLautstaerke(0); @@ -43,7 +59,7 @@ class RadioPlayerTest { rp.quieter(); assertThat(rp.getLautstaerke()).isEqualTo(0); } -/* + Jenkins config test @Test void getVolume() {