Browse Source

UsbPlayerTest.chooseItemTest First Case

feature-pr-USB-otherTests
sahar 3 years ago
parent
commit
2b0475f00c
  1. 29
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 17
      src/test/java/device/usbPlayer/UsbPlayerTest.java

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

@ -12,7 +12,7 @@ public class UsbPlayer implements Device {
private Boolean isConnected;
private Boolean isDefect;
int Lautstaerke = 0;
int soundWas =-1;
int soundWas = -1;
public USB_Stick USBDrive = new USB_Stick();
@ -104,8 +104,8 @@ public class UsbPlayer implements Device {
//**********search method*************
@Override
public void quieter() {
if(this.soundWas == -1){
if (Lautstaerke > 0 ) {
if (this.soundWas == -1) {
if (Lautstaerke > 0) {
Lautstaerke -= 1;
} else {
Lautstaerke = 0;
@ -116,7 +116,7 @@ public class UsbPlayer implements Device {
@Override
public void louder() {
if(this.soundWas == -1) {
if (this.soundWas == -1) {
if (Lautstaerke < 100) {
Lautstaerke += 1;
} else {
@ -126,7 +126,7 @@ public class UsbPlayer implements Device {
}
public void Louder_10() {
if(this.soundWas == -1) {
if (this.soundWas == -1) {
Lautstaerke += 10;
if (Lautstaerke > 100) {
Lautstaerke = 100;
@ -136,7 +136,7 @@ public class UsbPlayer implements Device {
}
public void quieter_10() {
if(this.soundWas == -1) {
if (this.soundWas == -1) {
Lautstaerke -= 10;
if (Lautstaerke < 0) {
Lautstaerke = 0;
@ -168,12 +168,11 @@ public class UsbPlayer implements Device {
@Override
public String getInfoText() {
String InfoText="";
String InfoText = "";
if (isAllAudio()) {
InfoText="USB Player is on : "+this.getPlayTrack();
}
else
InfoText="USB Player with no Albums";
InfoText = "USB Player is on : " + this.getPlayTrack();
} else
InfoText = "USB Player with no Albums";
return InfoText;
}
@ -184,9 +183,15 @@ public class UsbPlayer implements Device {
@Override
public String chooseItem(int itemNr) {
return null;
String songName="";
if (itemNr < this.getPlaylist().size()) {
songName= this.getPlaylist().get(itemNr ).toString();
}
return songName;
}
@Override
public String[] getItemList() {
return null;

17
src/test/java/device/usbPlayer/UsbPlayerTest.java

@ -542,6 +542,23 @@ class UsbPlayerTest {
Arguments.of("The Sound is unmuted ", up1,"unmuted","Sound level has changed","previous sound level is 0")
);
}//chooseItem
@ParameterizedTest
@MethodSource("chooseItem")
void chooseItemTest(String testName, String inputSong, String expectedResult) {
//int volumeNum = inputPlay.getLautstaerke();
assertThat(inputSong).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> chooseItem() {
USB_Stick USBDrive = new USB_Stick();
//first case
UsbPlayer up1 = new UsbPlayer(USBDrive);
return Stream.of(
Arguments.of("An Item from the Album was chosen ", up1.chooseItem(0), "Musik 01.mp3")
);
}
}
Loading…
Cancel
Save