Browse Source

test+productive code for case:1 of method prev in CDPlayer created.

feature-pr-cdPlayerPrev
JPANZO 3 years ago
parent
commit
fc6f610b6a
  1. 3
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 23
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -52,7 +52,8 @@ public class CDPlayer implements Device {
@Override
public void prev() {
List<String> playList = Arrays.asList(loadedCD.getPlayList());
this.actualPlayTrack=playList.get(playList.indexOf(actualPlayTrack)-1);
}
@Override

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

@ -197,4 +197,27 @@ class CDPlayerTest {
);
}
@ParameterizedTest
@MethodSource("prevTestData")
void prevTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){
for (int i = 0; i <anzClicks; i++) {
_cdPlayer.prev();
}
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> prevTestData () {
String[] audioPlayList = new String[]{"Audio 01", "Audio 02", "Audio 03", "Audio 04", "Audio 05"};
CD audioCD = new CD("Audio", audioPlayList);
CDPlayer cdPlayer1 = new CDPlayer();
cdPlayer1.tapOnCdFlap();
cdPlayer1.setCD(audioCD);
cdPlayer1.tapOnCdFlap();
cdPlayer1.next();
return Stream.of(
Arguments.of("[getActualPlayTrack() after 1x prev() starting by secondSong] => FirstSongSelected", "FirstSongSelected", cdPlayer1, 1, cdPlayer1.getSongByNumber(0))
);
}
}
Loading…
Cancel
Save