Browse Source

UsbPlayerTest.GoToTest Second Case

feature-pr-USB-10Louder
sahar 3 years ago
parent
commit
d6170a230c
  1. 9
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 8
      src/test/java/device/usbPlayer/UsbPlayerTest.java

9
src/main/java/device/usbPlayer/UsbPlayer.java

@ -202,8 +202,13 @@ public class UsbPlayer implements Device {
} }
public boolean GoTo(String songName){ public boolean GoTo(String songName){
playTrack = songName;
return true;
if(findSong(songName) != -1){
playTrack = songName;
return true;
}
else
//playTrack = songName;
return false;
} }
} }

8
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) { void findSongTest(String testName, int inputPlay, int expectedResult) {
//first case: the song is not in the Album //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);//songLoc1
assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);
//Second Case: the song is in the album //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); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);
@ -223,8 +223,12 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
UsbPlayer up1 = new UsbPlayer(); UsbPlayer up1 = new UsbPlayer();
up1.GoTo("Musik 03.mp3"); up1.GoTo("Musik 03.mp3");
UsbPlayer up2 = new UsbPlayer();
up2.GoTo("Musik 04.mp3");
return Stream.of( 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")
); );
} }

Loading…
Cancel
Save