From cb6236b18036dfc7201bffc64210040adebed298 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 21:29:56 +0100 Subject: [PATCH 01/14] UsbPlayerTest.louder_10_Test() first Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 4 ++++ .../java/device/usbPlayer/UsbPlayerTest.java | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 0a6e75d..925e55b 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -104,6 +104,10 @@ public class UsbPlayer implements Device { } } + public void Louder_10(){ + Lautstaerke += 10; + } + @Override public int getVolume() { return 0; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 70c0f7a..978c5db 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -114,7 +114,6 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } - //////////////// @ParameterizedTest @MethodSource("PrevOptions") void PrevTest(String testName, UsbPlayer inputPlay, String expectedResult) { @@ -137,4 +136,20 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("louder_10_Options") + void louder_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream louder_10_Options() { + UsbPlayer up1 = new UsbPlayer(); + up1.Louder_10(); + + return Stream.of( + Arguments.of("Volume was 0, should 10 ", up1, 10) + ); + } + } \ No newline at end of file From 3d3a1d8dfce9e905d8173d83364e0fea9862c806 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 21:35:19 +0100 Subject: [PATCH 02/14] UsbPlayerTest.louder_10_Test() second Case --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 978c5db..722f74e 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -146,9 +146,14 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { static Stream louder_10_Options() { UsbPlayer up1 = new UsbPlayer(); up1.Louder_10(); + UsbPlayer up2 = new UsbPlayer(); + for (int i = 0; i < 3; i++) {//3 + up2.Louder_10(); + } return Stream.of( - Arguments.of("Volume was 0, should 10 ", up1, 10) + Arguments.of("Volume was 0, should 10 ", up1, 10), + Arguments.of("Volume was increased 3 times :30 ", up2, 30) ); } From 959a6a3a5e2b82dcdf10916f3a9e364dff5230f0 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 21:43:17 +0100 Subject: [PATCH 03/14] UsbPlayerTest.louder_10_Test() third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 3 +++ src/test/java/device/usbPlayer/UsbPlayerTest.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 925e55b..d259fa9 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -106,6 +106,9 @@ public class UsbPlayer implements Device { public void Louder_10(){ Lautstaerke += 10; + if (Lautstaerke > 100) { + Lautstaerke = 100; + } } @Override diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 722f74e..e2801e1 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -150,10 +150,14 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { for (int i = 0; i < 3; i++) {//3 up2.Louder_10(); } + UsbPlayer up3 = new UsbPlayer(); + up3.setLautstaerke(100); + up3.Louder_10(); return Stream.of( Arguments.of("Volume was 0, should 10 ", up1, 10), - Arguments.of("Volume was increased 3 times :30 ", up2, 30) + Arguments.of("Volume was increased 3 times :30 ", up2, 30), + Arguments.of("Volume is 100 and doesn't change ", up3, 100) ); } From 601a10898fc84b114f6767c89cadde07796531c1 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 21:59:59 +0100 Subject: [PATCH 04/14] UsbPlayerTest.quieter_10_Test first Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 4 ++++ .../java/device/usbPlayer/UsbPlayerTest.java | 21 +++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index d259fa9..c2f51f7 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -111,6 +111,10 @@ public class UsbPlayer implements Device { } } + public void quieter_10(){ + Lautstaerke -= 10; + } + @Override public int getVolume() { return 0; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index e2801e1..03e1a50 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -136,28 +136,21 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest - @MethodSource("louder_10_Options") - void louder_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { + @MethodSource("quieter_10_Options") + void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { int volumeNum = inputPlay.getLautstaerke(); assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); } - static Stream louder_10_Options() { + static Stream quieter_10_Options() { UsbPlayer up1 = new UsbPlayer(); - up1.Louder_10(); - UsbPlayer up2 = new UsbPlayer(); - for (int i = 0; i < 3; i++) {//3 - up2.Louder_10(); - } - UsbPlayer up3 = new UsbPlayer(); - up3.setLautstaerke(100); - up3.Louder_10(); + up1.setLautstaerke(10); + up1.quieter_10(); return Stream.of( - Arguments.of("Volume was 0, should 10 ", up1, 10), - Arguments.of("Volume was increased 3 times :30 ", up2, 30), - Arguments.of("Volume is 100 and doesn't change ", up3, 100) + Arguments.of("Volume was 10, should be 0 ", up1, 0) ); } From 559b156bd51908b15ad8ccd3fb97416d187bdc96 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 22:21:50 +0100 Subject: [PATCH 05/14] UsbPlayerTest.quieter_10_Test second Case --- .../java/device/usbPlayer/UsbPlayerTest.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 03e1a50..737bf15 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -136,7 +136,32 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("louder_10_Options") + void louder_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream louder_10_Options() { + UsbPlayer up1 = new UsbPlayer(); + up1.Louder_10(); + + UsbPlayer up2 = new UsbPlayer(); + for (int i = 0; i <= 3; i++) { + up2.Louder_10(); + } + up2.quieter_10(); + UsbPlayer up3 = new UsbPlayer(); + up3.setLautstaerke(100); + up3.Louder_10(); + return Stream.of( + Arguments.of("Volume was 0, should be 10 ", up1, 10), + Arguments.of("Volume was 0, should be 30 ", up2, 30), + Arguments.of("Volume was 100, should stay 100 ", up3, 100) + ); + } @ParameterizedTest @MethodSource("quieter_10_Options") void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { @@ -149,8 +174,16 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { up1.setLautstaerke(10); up1.quieter_10(); + UsbPlayer up2 = new UsbPlayer(); + up2.setLautstaerke(50); + for (int i = 0; i < 3; i++) { + up2.quieter_10(); + } + + return Stream.of( - Arguments.of("Volume was 10, should be 0 ", up1, 0) + Arguments.of("Volume was 10, should be 0 ", up1, 0), + Arguments.of("Volume was 50, should be 20 ", up2, 20) ); } From 3d34b2c239cb88c4a839866359dc3ae508468c08 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 11 Feb 2022 22:25:23 +0100 Subject: [PATCH 06/14] UsbPlayerTest.quieter_10_Test third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 3 +++ src/test/java/device/usbPlayer/UsbPlayerTest.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index c2f51f7..dadba47 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -113,6 +113,9 @@ public class UsbPlayer implements Device { public void quieter_10(){ Lautstaerke -= 10; + if (Lautstaerke < 0) { + Lautstaerke = 0; + } } @Override diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 737bf15..03c5b2c 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -180,10 +180,13 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { up2.quieter_10(); } + UsbPlayer up3 = new UsbPlayer(); + up3.quieter_10(); return Stream.of( Arguments.of("Volume was 10, should be 0 ", up1, 0), - Arguments.of("Volume was 50, should be 20 ", up2, 20) + Arguments.of("Volume was 50, should be 20 ", up2, 20), + Arguments.of("Volume was 0, should stay 0 ", up3, 0) ); } From 692a519b762862809d2ee60739dbec4ad22c2e42 Mon Sep 17 00:00:00 2001 From: sahar Date: Sat, 12 Feb 2022 16:46:11 +0100 Subject: [PATCH 07/14] UsbPlayerTest.findSongTest first Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 4 ++++ .../java/device/usbPlayer/UsbPlayerTest.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index dadba47..4be2046 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -183,4 +183,8 @@ public class UsbPlayer implements Device { } + public int findSong(String song){ + return -1; + } + } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 03c5b2c..c285d79 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -190,4 +190,20 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("FindSongOptions") + void findSongTest(String testName, UsbPlayer inputPlay, int expectedResult) { + int songLocation = inputPlay.findSong("song 4"); + assertThat(songLocation).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream FindSongOptions() { + UsbPlayer up1 = new UsbPlayer(); + + return Stream.of( + Arguments.of("The song is not in the Album", up1, -1) + + ); + } + } \ No newline at end of file From 40ff19f9351f2f079849add0994ee801cc4992f5 Mon Sep 17 00:00:00 2001 From: sahar Date: Sat, 12 Feb 2022 23:12:06 +0100 Subject: [PATCH 08/14] UsbPlayerTest.findSongTest Second Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 18 ++++++++++++++++-- .../java/device/usbPlayer/UsbPlayerTest.java | 15 ++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 4be2046..501c451 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -183,8 +183,22 @@ public class UsbPlayer implements Device { } - public int findSong(String song){ - return -1; + public int findSong(String songName){ + + int songIndex =-1, index=-1; + String song; + + for (int j = 0; j < getPlaylist().size(); j++) { + + song = getPlaylist().get(j); + songIndex=song.indexOf(songName); + + if (songIndex != -1) { + index = j; + break; + } + } + return index; } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index c285d79..5d979d8 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -192,16 +192,21 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { @ParameterizedTest @MethodSource("FindSongOptions") - void findSongTest(String testName, UsbPlayer inputPlay, int expectedResult) { - int songLocation = inputPlay.findSong("song 4"); - assertThat(songLocation).describedAs(testName).isEqualTo(expectedResult); + void findSongTest(String testName, int inputPlay, int expectedResult) { + //first case: the song is not in the Album + // int songLoc1 = inputPlay.findSong("song 4"); + assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);//songLoc1 + //Second Case: the song is in the album + // int songLoc2 = inputPlay.findSong("Musik 02"); + assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); + } static Stream FindSongOptions() { UsbPlayer up1 = new UsbPlayer(); - return Stream.of( - Arguments.of("The song is not in the Album", up1, -1) + Arguments.of("The song is not in the Album", up1.findSong("song 4"), -1), + Arguments.of("The song is in the Album", up1.findSong("Musik 02"), 1) ); } From d00dd96833904a9dfe5ed0f87940bb8567a30608 Mon Sep 17 00:00:00 2001 From: sahar Date: Sat, 12 Feb 2022 23:18:25 +0100 Subject: [PATCH 09/14] UsbPlayerTest.findSongTest Third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 501c451..0f824c7 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -191,7 +191,7 @@ public class UsbPlayer implements Device { for (int j = 0; j < getPlaylist().size(); j++) { song = getPlaylist().get(j); - songIndex=song.indexOf(songName); + songIndex=song.toLowerCase().indexOf(songName.toLowerCase()); if (songIndex != -1) { index = j; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 5d979d8..cb6831c 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -206,7 +206,8 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up1 = new UsbPlayer(); return Stream.of( Arguments.of("The song is not in the Album", up1.findSong("song 4"), -1), - Arguments.of("The song is in the Album", up1.findSong("Musik 02"), 1) + Arguments.of("The song is in the Album", up1.findSong("Musik 02"), 1), + Arguments.of("Name of the Song is in lower case :", up1.findSong("musik 02"), 1) ); } From f8c8ff9120d2f295d41ba7b52fa03e47d5b32109 Mon Sep 17 00:00:00 2001 From: sahar Date: Sat, 12 Feb 2022 23:20:36 +0100 Subject: [PATCH 10/14] UsbPlayerTest.findSongTest Forth Case --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index cb6831c..bea06ae 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -207,8 +207,8 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { return Stream.of( Arguments.of("The song is not in the Album", up1.findSong("song 4"), -1), Arguments.of("The song is in the Album", up1.findSong("Musik 02"), 1), - Arguments.of("Name of the Song is in lower case :", up1.findSong("musik 02"), 1) - + Arguments.of("Name of the Song is in lower case :", up1.findSong("musik 02"), 1), + Arguments.of("Name of the Song is in upper case :", up1.findSong("MUSIK 02"), 1) ); } From dfeb952e3670acca4d28fc90f63e84e05869f53e Mon Sep 17 00:00:00 2001 From: sahar Date: Sun, 13 Feb 2022 14:04:11 +0100 Subject: [PATCH 11/14] UsbPlayerTest.GoToTest First Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 5 +++++ .../java/device/usbPlayer/UsbPlayerTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 0f824c7..a0956ca 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -201,4 +201,9 @@ public class UsbPlayer implements Device { return index; } + public boolean GoTo(String songName){ + playTrack = songName; + return true; + } + } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index bea06ae..9e1f4b1 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -212,4 +212,22 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("GoToOptions") + void GoToTest(String testName, UsbPlayer inputPlay, String expectedResult) { + String current_Track = inputPlay.getPlayTrack(); + assertThat(current_Track).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream GoToOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.GoTo("Musik 03.mp3"); + + return Stream.of( + Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3") + + ); + } + + } \ No newline at end of file From d6170a230cb55bb3b402517c61c3dfaba0ec772a Mon Sep 17 00:00:00 2001 From: sahar Date: Sun, 13 Feb 2022 14:22:02 +0100 Subject: [PATCH 12/14] UsbPlayerTest.GoToTest Second Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 9 +++++++-- src/test/java/device/usbPlayer/UsbPlayerTest.java | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index a0956ca..3c5d333 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -202,8 +202,13 @@ public class UsbPlayer implements Device { } public boolean GoTo(String songName){ - playTrack = songName; - return true; + if(findSong(songName) != -1){ + playTrack = songName; + return true; + } + else + //playTrack = songName; + return false; } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 9e1f4b1..daa1900 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -195,7 +195,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { void findSongTest(String testName, int inputPlay, int expectedResult) { //first case: the song is not in the Album // int songLoc1 = inputPlay.findSong("song 4"); - assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);//songLoc1 + assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); //Second Case: the song is in the album // int songLoc2 = inputPlay.findSong("Musik 02"); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); @@ -223,8 +223,12 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up1 = new UsbPlayer(); up1.GoTo("Musik 03.mp3"); + UsbPlayer up2 = new UsbPlayer(); + up2.GoTo("Musik 04.mp3"); + return Stream.of( - Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3") + Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3"), + Arguments.of("Go to Song that is not in the Album: Musik 04.mp3 ", up2, "Musik 01.mp3") ); } From 5a74e5ea751d9bc4888ce4122fa8cfce6a167f86 Mon Sep 17 00:00:00 2001 From: sahar Date: Sun, 13 Feb 2022 14:47:50 +0100 Subject: [PATCH 13/14] UsbPlayerTest.GoToTest Third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 3c5d333..8e38ed0 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -203,7 +203,7 @@ public class UsbPlayer implements Device { public boolean GoTo(String songName){ if(findSong(songName) != -1){ - playTrack = songName; + playTrack = getPlaylist().get(findSong(songName));//songName; return true; } else diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index daa1900..20d83d5 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -226,9 +226,13 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up2 = new UsbPlayer(); up2.GoTo("Musik 04.mp3"); + UsbPlayer up3 = new UsbPlayer(); + up3.GoTo("Musik 02"); + return Stream.of( Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3"), - Arguments.of("Go to Song that is not in the Album: Musik 04.mp3 ", up2, "Musik 01.mp3") + Arguments.of("Go to Song that is not in the Album: Musik 04.mp3 ", up2, "Musik 01.mp3"), + Arguments.of("Go to Song without writing the full Name : Musik 02 ", up3, "Musik 02.mp3") ); } From d57de4380a416d172bb46c247ccf7c57db7d67fd Mon Sep 17 00:00:00 2001 From: sahar Date: Sun, 13 Feb 2022 14:53:41 +0100 Subject: [PATCH 14/14] UsbPlayerTest.GoToTest Forth Case --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 20d83d5..2a613fb 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -229,10 +229,15 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up3 = new UsbPlayer(); up3.GoTo("Musik 02"); + UsbPlayer up4 = new UsbPlayer(); + up4.next(); + up4.GoTo("Musik"); + return Stream.of( Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3"), Arguments.of("Go to Song that is not in the Album: Musik 04.mp3 ", up2, "Musik 01.mp3"), - Arguments.of("Go to Song without writing the full Name : Musik 02 ", up3, "Musik 02.mp3") + Arguments.of("Go to Song without writing the full Name : Musik 02 ", up3, "Musik 02.mp3"), + Arguments.of("Go to Song and write a Name that many songs starts with : Musik", up4, "Musik 01.mp3") ); }