From e68d22daf4785ce3fda026d88cd7893be19a38dd Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:20:59 +0100 Subject: [PATCH 01/13] UsbPlayerTest.isAllAudioTestTest First Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 4 ++-- .../java/device/usbPlayer/UsbPlayerTest.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 8e38ed0..41189a4 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -69,14 +69,14 @@ public class UsbPlayer implements Device { } //**********search method************* - private boolean isAllAudio() { + public boolean isAllAudio() { String song = ""; boolean flag = true; for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") | song.equals(".mp4") | song.equals(".wav")) { + if (song.equals(".mp3") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 2a613fb..5f09063 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -242,5 +242,22 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { ); } + @ParameterizedTest + @MethodSource("isAllAudioOptions") + void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) { + // String current_Track = inputPlay.getPlayTrack(); + assertThat(inputTestResult).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream isAllAudioOptions() { + UsbPlayer up1 = new UsbPlayer(); + //up1.GoTo("Musik 03.mp3"); + + return Stream.of( + Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true) + + ); + } + } \ No newline at end of file From 3fa2cfb8627ffe073896a0cd888e7abaab3ec23f Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:25:55 +0100 Subject: [PATCH 02/13] UsbPlayerTest.isAllAudioTestTest Second Case (mp4) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 41189a4..1c18978 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") ) { + if (song.equals(".mp3") | song.equals(".mp4") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 5f09063..37acd4a 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -251,10 +251,15 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { static Stream isAllAudioOptions() { UsbPlayer up1 = new UsbPlayer(); - //up1.GoTo("Musik 03.mp3"); - + UsbPlayer up2=new UsbPlayer(); + ArrayList Pl = new ArrayList(); + Pl.add("Musik 01.mp4"); + Pl.add("Musik 02.mp4"); + Pl.add("Musik 03.mp4"); + up2.setPlaylist(Pl); return Stream.of( - Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true) + Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true), + Arguments.of("Go to Song : Musik 03.mp3 ", up2.isAllAudio(), true) ); } From 36b6cc48c9f820ec15d9ff48bb7548c2f499dfcd Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:30:54 +0100 Subject: [PATCH 03/13] UsbPlayerTest.isAllAudioTestTest Third Case (m4a) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- .../java/device/usbPlayer/UsbPlayerTest.java | 37 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 1c18978..2dac1b0 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") | song.equals(".mp4") ) { + if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 37acd4a..fc121f7 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -3,6 +3,7 @@ package device.usbPlayer; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; + import java.util.stream.Stream; import java.util.ArrayList; @@ -48,12 +49,12 @@ class UsbPlayerTest { } -@ParameterizedTest -@MethodSource("louderOptions") -void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { - int volumeNum = inputPlay.getLautstaerke(); - assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); -} + @ParameterizedTest + @MethodSource("louderOptions") + void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } static Stream louderOptions() { UsbPlayer up11 = new UsbPlayer(); @@ -149,7 +150,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up2 = new UsbPlayer(); for (int i = 0; i <= 3; i++) { - up2.Louder_10(); + up2.Louder_10(); } up2.quieter_10(); @@ -162,6 +163,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { 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) { @@ -194,10 +196,10 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { @MethodSource("FindSongOptions") void findSongTest(String testName, int inputPlay, int expectedResult) { //first case: the song is not in the Album - // int songLoc1 = inputPlay.findSong("song 4"); + // int songLoc1 = inputPlay.findSong("song 4"); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); //Second Case: the song is in the album - // int songLoc2 = inputPlay.findSong("Musik 02"); + // int songLoc2 = inputPlay.findSong("Musik 02"); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); } @@ -245,21 +247,30 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { @ParameterizedTest @MethodSource("isAllAudioOptions") void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) { - // String current_Track = inputPlay.getPlayTrack(); + // String current_Track = inputPlay.getPlayTrack(); assertThat(inputTestResult).describedAs(testName).isEqualTo(expectedResult); } static Stream isAllAudioOptions() { UsbPlayer up1 = new UsbPlayer(); - UsbPlayer up2=new UsbPlayer(); + + UsbPlayer up2 = new UsbPlayer(); ArrayList Pl = new ArrayList(); Pl.add("Musik 01.mp4"); Pl.add("Musik 02.mp4"); Pl.add("Musik 03.mp4"); up2.setPlaylist(Pl); +//m4a + UsbPlayer up3 = new UsbPlayer(); + ArrayList Pl1 = new ArrayList(); + Pl1.add("Musik 01.m4a"); + Pl1.add("Musik 02.m4a"); + Pl1.add("Musik 03.m4a"); + up3.setPlaylist(Pl); return Stream.of( - Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true), - Arguments.of("Go to Song : Musik 03.mp3 ", up2.isAllAudio(), true) + Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), + Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), + Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true) ); } From 356bcaf539c4239342c13ce70f38cc6e17d66914 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:33:54 +0100 Subject: [PATCH 04/13] UsbPlayerTest.isAllAudioTestTest Forth Case (flac) --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index fc121f7..8999478 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -252,25 +252,34 @@ class UsbPlayerTest { } static Stream isAllAudioOptions() { + //mp3 UsbPlayer up1 = new UsbPlayer(); - + //mp4 UsbPlayer up2 = new UsbPlayer(); ArrayList Pl = new ArrayList(); Pl.add("Musik 01.mp4"); Pl.add("Musik 02.mp4"); Pl.add("Musik 03.mp4"); up2.setPlaylist(Pl); -//m4a + //m4a UsbPlayer up3 = new UsbPlayer(); ArrayList Pl1 = new ArrayList(); Pl1.add("Musik 01.m4a"); Pl1.add("Musik 02.m4a"); Pl1.add("Musik 03.m4a"); up3.setPlaylist(Pl); + //Flac + UsbPlayer up4 = new UsbPlayer(); + ArrayList Pl2 = new ArrayList(); + Pl2.add("Musik 01.flac"); + Pl2.add("Musik 02.flac"); + Pl2.add("Musik 03.flac"); + up4.setPlaylist(Pl); return Stream.of( Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), - Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true) + Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true), + Arguments.of("Check if the Files are .flac ", up4.isAllAudio(), true) ); } From 0188a43e114a3e4575770846859c1275a492d520 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:42:24 +0100 Subject: [PATCH 05/13] UsbPlayerTest.isAllAudioTestTest Forth Case correction(wav) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 2dac1b0..1ce300d 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a") ) { + if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 8999478..0d5b6ca 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -267,19 +267,19 @@ class UsbPlayerTest { Pl1.add("Musik 01.m4a"); Pl1.add("Musik 02.m4a"); Pl1.add("Musik 03.m4a"); - up3.setPlaylist(Pl); + up3.setPlaylist(Pl1); //Flac UsbPlayer up4 = new UsbPlayer(); ArrayList Pl2 = new ArrayList(); - Pl2.add("Musik 01.flac"); - Pl2.add("Musik 02.flac"); - Pl2.add("Musik 03.flac"); - up4.setPlaylist(Pl); + Pl2.add("Musik 01.wav"); + Pl2.add("Musik 02.wav"); + Pl2.add("Musik 03.wav"); + up4.setPlaylist(Pl2); return Stream.of( Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true), - Arguments.of("Check if the Files are .flac ", up4.isAllAudio(), true) + Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true) ); } From 3175b14cde283dbf76f7a3f6ac32f96cf23035cc Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:45:34 +0100 Subject: [PATCH 06/13] UsbPlayerTest.isAllAudioTestTest Fifth Case (wma) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 1ce300d..b3ea2a8 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav") ) { + if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav")| song.equals(".wma") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 0d5b6ca..d038d60 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -268,18 +268,26 @@ class UsbPlayerTest { Pl1.add("Musik 02.m4a"); Pl1.add("Musik 03.m4a"); up3.setPlaylist(Pl1); - //Flac + //wav UsbPlayer up4 = new UsbPlayer(); ArrayList Pl2 = new ArrayList(); Pl2.add("Musik 01.wav"); Pl2.add("Musik 02.wav"); Pl2.add("Musik 03.wav"); up4.setPlaylist(Pl2); + //wma + UsbPlayer up5 = new UsbPlayer(); + ArrayList Pl3 = new ArrayList(); + Pl3.add("Musik 01.wma"); + Pl3.add("Musik 02.wma"); + Pl3.add("Musik 03.wma"); + up5.setPlaylist(Pl3); return Stream.of( Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true), - Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true) + Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true), + Arguments.of("Check if the Files are .wma ", up5.isAllAudio(), true) ); } From b2e9f26d0a0ef6c12d7ec8081adb3895c5b75a52 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:49:10 +0100 Subject: [PATCH 07/13] UsbPlayerTest.isAllAudioTestTest Sixth Case (aac) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index b3ea2a8..992ba76 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { song = Playlist.get(i).substring(Playlist.get(i).length() - 4); - if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav")| song.equals(".wma") ) { + if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav")| song.equals(".wma")| song.equals(".aac") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index d038d60..1c8ae91 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -282,12 +282,21 @@ class UsbPlayerTest { Pl3.add("Musik 02.wma"); Pl3.add("Musik 03.wma"); up5.setPlaylist(Pl3); + //aac + UsbPlayer up6 = new UsbPlayer(); + ArrayList Pl4 = new ArrayList(); + Pl4.add("Musik 01.aac"); + Pl4.add("Musik 02.aac"); + Pl4.add("Musik 03.aac"); + up6.setPlaylist(Pl4); + return Stream.of( Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true), Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true), - Arguments.of("Check if the Files are .wma ", up5.isAllAudio(), true) + Arguments.of("Check if the Files are .wma ", up5.isAllAudio(), true), + Arguments.of("Check if the Files are .aac ", up6.isAllAudio(), true) ); } From f98223ea57039f6eb5cd6e95c9ec7dacfd3a31e5 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:03:13 +0100 Subject: [PATCH 08/13] UsbPlayerTest.isAllAudioTestTest seventh Case (mixed Audio and txt) --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 1c8ae91..9c553f8 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -289,6 +289,13 @@ class UsbPlayerTest { Pl4.add("Musik 02.aac"); Pl4.add("Musik 03.aac"); up6.setPlaylist(Pl4); + //mixed Audio and text Files in the Album + UsbPlayer up7 = new UsbPlayer(); + ArrayList Pl5 = new ArrayList(); + Pl5.add("Musik 01.aac"); + Pl5.add("Musik 02.txt"); + Pl5.add("Musik 03.aac"); + up7.setPlaylist(Pl5); return Stream.of( Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), @@ -296,7 +303,8 @@ class UsbPlayerTest { Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true), Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true), Arguments.of("Check if the Files are .wma ", up5.isAllAudio(), true), - Arguments.of("Check if the Files are .aac ", up6.isAllAudio(), true) + Arguments.of("Check if the Files are .aac ", up6.isAllAudio(), true), + Arguments.of("Check case of mixed Files", up7.isAllAudio(), false) ); } From 280b8843f2544821bbeab4f657a0d23be011f788 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:16:05 +0100 Subject: [PATCH 09/13] UsbPlayerTest.GoToFirstTest first Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 3 +++ .../java/device/usbPlayer/UsbPlayerTest.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 992ba76..194128e 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -211,4 +211,7 @@ public class UsbPlayer implements Device { return false; } + public void GoToFirst() { + setPlayTrack("Musik 01.mp3"); + } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 9c553f8..5b12b03 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -309,5 +309,22 @@ class UsbPlayerTest { ); } + //GoToFirst() + @ParameterizedTest + @MethodSource("GoToFirstOptions") + void GoToFirstTest(String testName, UsbPlayer inputUSB, String expectedResult) { + String firstSong = inputUSB.getPlayTrack(); + assertThat(firstSong ).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream GoToFirstOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.GoToFirst(); + + return Stream.of( + Arguments.of("It should go to the first Song ", up1,up1.getPlaylist().get(0)) + ); + } + } \ No newline at end of file From e21ac149324f210301010b05544c2fb2415f84a3 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:18:51 +0100 Subject: [PATCH 10/13] UsbPlayerTest.GoToFirstTest Second Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/usbPlayer/UsbPlayerTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 194128e..2a80289 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -212,6 +212,6 @@ public class UsbPlayer implements Device { } public void GoToFirst() { - setPlayTrack("Musik 01.mp3"); + setPlayTrack(getPlaylist().get(0)); } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 5b12b03..762cd84 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -321,8 +321,13 @@ class UsbPlayerTest { UsbPlayer up1 = new UsbPlayer(); up1.GoToFirst(); + UsbPlayer up2 = new UsbPlayer(); + up2.GoToFirst(); + up2.GoToFirst(); + return Stream.of( - Arguments.of("It should go to the first Song ", up1,up1.getPlaylist().get(0)) + Arguments.of("It should go to the first Song ", up1,up1.getPlaylist().get(0)), + Arguments.of("Call the function twice and it stills go to the first Song ", up2,up2.getPlaylist().get(0)) ); } From ba0578b7baaf5be475c8f12fae5254f846ab4017 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:22:50 +0100 Subject: [PATCH 11/13] UsbPlayerTest.GoToFirstTest third Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 1 + src/test/java/device/usbPlayer/UsbPlayerTest.java | 7 ++++++- 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 2a80289..c1233c6 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -212,6 +212,7 @@ public class UsbPlayer implements Device { } public void GoToFirst() { + //go to the first song in the list setPlayTrack(getPlaylist().get(0)); } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 762cd84..25359e6 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -325,9 +325,14 @@ class UsbPlayerTest { up2.GoToFirst(); up2.GoToFirst(); + UsbPlayer up3 = new UsbPlayer(); + up3.next(); + up3.GoToFirst(); + return Stream.of( Arguments.of("It should go to the first Song ", up1,up1.getPlaylist().get(0)), - Arguments.of("Call the function twice and it stills go to the first Song ", up2,up2.getPlaylist().get(0)) + Arguments.of("Call the function twice and it stills go to the first Song ", up2,up2.getPlaylist().get(0)), + Arguments.of("go to the next Song then back to first Song ", up3,up3.getPlaylist().get(0)) ); } From 27f942760b3a051186eb794ad4a2f86c5f0638c5 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:35:16 +0100 Subject: [PATCH 12/13] UsbPlayerTest.GoToLastTest 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 c1233c6..1f395c8 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -215,4 +215,8 @@ public class UsbPlayer implements Device { //go to the first song in the list setPlayTrack(getPlaylist().get(0)); } + + public void GoToLast() { + setPlayTrack("Musik 03.mp3"); + } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 25359e6..8822fde 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -336,5 +336,21 @@ class UsbPlayerTest { ); } + @ParameterizedTest + @MethodSource("GoToLastOptions") + void GoToLastTest(String testName, UsbPlayer inputUSB, String expectedResult) { + String firstSong = inputUSB.getPlayTrack(); + assertThat(firstSong ).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream GoToLastOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.GoToLast(); + + + return Stream.of( + Arguments.of("It should go to the first Song ", up1,"Musik 03.mp3") + ); + } } \ No newline at end of file From 15ddf95671998e3ed736d151e654817feada8328 Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 18:39:16 +0100 Subject: [PATCH 13/13] UsbPlayerTest.GoToLastTest first Case correction --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 8822fde..042a4a9 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -344,6 +344,7 @@ class UsbPlayerTest { } static Stream GoToLastOptions() { + //first case UsbPlayer up1 = new UsbPlayer(); up1.GoToLast();