From 64d051326de6e2033428c0157b33731b154e53ab Mon Sep 17 00:00:00 2001 From: JPANZO Date: Wed, 9 Feb 2022 19:28:00 +0100 Subject: [PATCH] Base-Test for method next created. --- src/main/java/device/cdPlayer/CDPlayer.java | 8 ++++++ .../java/device/cdPlayer/CDPlayerTest.java | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index b7134fa..209e646 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -114,4 +114,12 @@ public class CDPlayer implements Device { return false; } + public String getSongByNumber(int songNr){ + return ""; + } + + public String getActualPlayTrack() { + return actualPlayTrack; + } + } diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index 91ef68a..694460a 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/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 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)) + ); + } + } \ No newline at end of file