Browse Source

Merge commit 'd1cb0386ba8ee77bb957c37f13dc82ccf10155fb' into HEAD

feature-pr-cdPlayerNextTest
Jenkins 3 years ago
parent
commit
029d19a2ed
  1. 12
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 25
      src/test/java/device/cdPlayer/CDPlayerTest.java

12
src/main/java/device/cdPlayer/CDPlayer.java

@ -42,7 +42,10 @@ public class CDPlayer implements Device {
@Override
public void next() {
List<String> playList = Arrays.asList(loadedCD.getPlayList());
int indexOfActualPlayTrack=playList.indexOf(actualPlayTrack);
this.actualPlayTrack=playList.get(indexOfActualPlayTrack +1);
}
@Override
@ -114,4 +117,13 @@ public class CDPlayer implements Device {
return false;
}
public String getSongByNumber(int songNr){
List<String> playList = Arrays.asList(loadedCD.getPlayList());
return playList.get(songNr);
}
public String getActualPlayTrack() {
return actualPlayTrack;
}
}

25
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -153,4 +153,29 @@ class CDPlayerTest {
);
}
@ParameterizedTest
@MethodSource("nextTestData")
void nextTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.next();
}
if(testDirection.equals("SecondSongSelected")){
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
}
}
static Stream<Arguments> nextTestData () {
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
CD audioCD=new CD("Audio",audioPlayList);
CDPlayer cdPlayer=new CDPlayer();
cdPlayer.tapOnCdFlap();
cdPlayer.setCD(audioCD);
cdPlayer.tapOnCdFlap();
return Stream.of(
Arguments.of("[getActualPlayTrack() after 1x next() starting by firstSong] => SecondSongSelected","SecondSongSelected", cdPlayer, 1, cdPlayer.getSongByNumber(1))
);
}
}
Loading…
Cancel
Save