Browse Source

Merge commit '7b164b510a89feb81909204e3471df8306f96789' into HEAD

feature-pr-cdPlayerNextTest
Jenkins 3 years ago
parent
commit
a476dd0ccc
  1. 42
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 49
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -8,13 +8,14 @@ public class RadioPlayer implements Device {
public RadioPlayer() {
super();
Playlist.add("Radio YouFM");
Playlist.add("Radio Teddy");
Playlist.add("Radio MegaHits");
Playlist.add("YouFM");
Playlist.add("Teddy");
Playlist.add("MegaHits");
playTrack=Playlist.get(0);
}
ArrayList<String> Playlist=new ArrayList<String>();
int Lautstaerke = 0;
String playTrack="";
@ -26,6 +27,41 @@ public class RadioPlayer implements Device {
return Lautstaerke;
}
public void changeRegion(String region){
switch (region) {
case "BY":
Playlist.clear();
Playlist.add("Antenne Bayern");
Playlist.add("Bayern 1");
Playlist.add("Bayern 3");
Playlist.add("Hit Radio N1");
playTrack=Playlist.get(0);
break;
case "HE":
Playlist.clear();
Playlist.add("Hit Radio FFH");
Playlist.add("HR 1");
Playlist.add("HR 3");
Playlist.add("You FM");
playTrack=Playlist.get(0);
break;
case "BW":
Playlist.clear();
Playlist.add("DASDING");
Playlist.add("SWR 1");
Playlist.add("SWR 3");
Playlist.add("sunshine live");
playTrack=Playlist.get(0);
break;
default:
Playlist.clear();
Playlist.add("YouFM");
Playlist.add("Teddy");
Playlist.add("MegaHits");
playTrack=Playlist.get(0);
break;
}
}
@Override
public void louder() {

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

@ -44,35 +44,30 @@ class RadioPlayerTest {
);
}
/*
@Test
void louder() {
rp.setLautstaerke(0);
rp.louder();
assertThat(rp.getLautstaerke()).isEqualTo(1);
@ParameterizedTest
@MethodSource("changeRegionOptions")
void changeRegionTest(String testName, RadioPlayer testRp, String expectedResult) {
String station = testRp.playTrack;
assertThat(station).describedAs(testName).isEqualTo(expectedResult);
}
@Test
void louderMax() {
rp.setLautstaerke(100);
rp.louder();
assertThat(rp.getLautstaerke()).isEqualTo(100);
}
static Stream<Arguments> changeRegionOptions() {
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
RadioPlayer rp3 = new RadioPlayer();
rp1.changeRegion("BY");
rp2.changeRegion("HE");
rp3.changeRegion("BW");
@Test
void quieter() {
rp.setLautstaerke(1);
rp.quieter();
assertThat(rp.getLautstaerke()).isEqualTo(0);
}
@Test
void quieterMax() {
rp.setLautstaerke(0);
rp.quieter();
assertThat(rp.getLautstaerke()).isEqualTo(0);
return Stream.of(
Arguments.of("Test change Region to Bayern", rp1, "Antenne Bayern"),
Arguments.of("Test change Region to Hessen", rp2, "Hit Radio FFH"),
Arguments.of("Test change Region to Baden-Wuerttemberg", rp3, "DASDING")
);
}
Jenkins config test
/*
@Test
void getVolume() {
}
@ -94,9 +89,9 @@ class RadioPlayerTest {
rp2.prev();
rp3.prev();
return Stream.of(
Arguments.of("Next Station Test", rp1, "Radio Teddy"),
Arguments.of("Prev Station Test", rp2, "Radio YouFM"),
Arguments.of("Prev works on first Station ", rp3, "Radio MegaHits")
Arguments.of("Next Station Test", rp1, "Teddy"),
Arguments.of("Prev Station Test", rp2, "YouFM"),
Arguments.of("Prev works on first Station ", rp3, "MegaHits")
);
}

Loading…
Cancel
Save