Browse Source

added test and code for second region to changeRegion()

feature-pr-changeRegion
Jan Ortner 3 years ago
parent
commit
25148dfdc5
  1. 20
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 16
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -27,13 +27,31 @@ public class RadioPlayer implements Device {
return Lautstaerke; return Lautstaerke;
} }
public void changeRegion(){
public void changeRegion(String region){
switch (region) {
case "Bayern":
Playlist.clear(); Playlist.clear();
Playlist.add("Antenne Bayern"); Playlist.add("Antenne Bayern");
Playlist.add("Bayern 1"); Playlist.add("Bayern 1");
Playlist.add("Bayern 3"); Playlist.add("Bayern 3");
Playlist.add("Hit Radio N1"); Playlist.add("Hit Radio N1");
playTrack=Playlist.get(0); playTrack=Playlist.get(0);
break;
case "Hessen":
Playlist.clear();
Playlist.add("Hit Radio FFH");
Playlist.add("HR 1");
Playlist.add("HR 3");
Playlist.add("You FM");
playTrack=Playlist.get(0);
break;
default:
Playlist.clear();
Playlist.add("YouFM");
Playlist.add("Teddy");
Playlist.add("MegaHits");
playTrack=Playlist.get(0);
}
} }
@Override @Override

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

@ -46,18 +46,20 @@ class RadioPlayerTest {
@ParameterizedTest @ParameterizedTest
@MethodSource("changeRegionOptions") @MethodSource("changeRegionOptions")
void changeFrequencyTest(String testName, RadioPlayer testRp, String expectedResult) {
void changeRegionTest(String testName, RadioPlayer testRp, String expectedResult) {
String station = testRp.playTrack; String station = testRp.playTrack;
assertThat(station).describedAs(testName).isEqualTo(expectedResult); assertThat(station).describedAs(testName).isEqualTo(expectedResult);
} }
static Stream<Arguments> changeRegionOptions() { static Stream<Arguments> changeRegionOptions() {
RadioPlayer rp1 = new RadioPlayer(); RadioPlayer rp1 = new RadioPlayer();
rp1.changeRegion();
RadioPlayer rp2 = new RadioPlayer();
rp1.changeRegion("Bayern");
rp2.changeRegion("Hessen");
return Stream.of( return Stream.of(
Arguments.of("Test change Region to Bayern", rp1, "Antenne Bayern")
Arguments.of("Test change Region to Bayern", rp1, "Antenne Bayern"),
Arguments.of("Test change Region to Hessen", rp2, "Hit Radio FFH")
); );
} }
@ -84,9 +86,9 @@ class RadioPlayerTest {
rp2.prev(); rp2.prev();
rp3.prev(); rp3.prev();
return Stream.of( 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