Browse Source

Merge commit 'e8a5a507dfd85ef5696a8287f3c403cc66ce7a01' into HEAD

feature-pr-changeRegion
Jenkins 3 years ago
parent
commit
bdc3221c16
  1. 14
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 30
      src/test/java/device/radioPlayer/RadioPlayerTest.java

14
src/main/java/device/radioPlayer/RadioPlayer.java

@ -29,20 +29,14 @@ public class RadioPlayer implements Device {
@Override
public void louder() {
if(Lautstaerke < 100) {
Lautstaerke += 1;
} else {
Lautstaerke = 100;
}
if(Lautstaerke < 100){Lautstaerke+=1;}
else Lautstaerke = 100;
}
@Override
public void quieter() {
if(Lautstaerke > 0) {
Lautstaerke -= 1;
} else {
Lautstaerke = 0;
}
if(Lautstaerke > 0){Lautstaerke-=1;}
else Lautstaerke = 0;
}
@Override
public int getVolume() {

30
src/test/java/device/radioPlayer/RadioPlayerTest.java

@ -16,7 +16,35 @@ 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<Arguments> quieterLouderOptions() {
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
RadioPlayer rp3 = new RadioPlayer();
RadioPlayer rp4 = new RadioPlayer();
rp1.setLautstaerke(0);
rp1.louder();
rp2.setLautstaerke(100);
rp2.louder();
rp3.setLautstaerke(1);
rp3.quieter();
rp4.setLautstaerke(0);
rp4.quieter();
return Stream.of(
Arguments.of("Test for one step louder", rp1, 1),
Arguments.of("Test for max louder", rp2, 100),
Arguments.of("Test for one step quieter", rp3, 0),
Arguments.of("Test for min quieter", rp4, 0)
);
}
/*
@Test
void louder() {
rp.setLautstaerke(0);
@ -43,7 +71,7 @@ class RadioPlayerTest {
rp.quieter();
assertThat(rp.getLautstaerke()).isEqualTo(0);
}
/*
Jenkins config test
@Test
void getVolume() {

Loading…
Cancel
Save