Browse Source

Method changePlaySource of CDPlayer tested on activeSource=CDDrive -> shouldReturnCDWechseler.

feature-pr-BordComputer-setDevices
JPANZO 3 years ago
parent
commit
43f556fa6f
  1. 13
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 19
      src/main/java/device/cdPlayer/CDWechseler.java
  3. 16
      src/test/java/device/cdPlayer/CDPlayerTest.java

13
src/main/java/device/cdPlayer/CDPlayer.java

@ -20,6 +20,9 @@ public class CDPlayer implements Device {
private String actualPlayTrack="";
private CD loadedCD=null;
private CDWechseler cdWechseler;
private String activeSource="CDDrive";//or CDWechseler
@Override
public void louder() {
if(volume < 100) {
@ -48,9 +51,7 @@ public class CDPlayer implements Device {
List<String> playList = Arrays.asList(loadedCD.getPlayList());
int indexOfActualPlayTrack=playList.indexOf(actualPlayTrack);
int indexOfNextPlayTrack=(indexOfActualPlayTrack+1)%loadedCD.getPlayList().length;
//System.out.println("actualIndex= "+indexOfActualPlayTrack);
this.actualPlayTrack=playList.get(indexOfNextPlayTrack );
//System.out.println("nextSong= "+actualPlayTrack);
}
@Override
@ -131,6 +132,10 @@ public class CDPlayer implements Device {
}
return null;
}
public String changePlaySource(){
this.activeSource="CDWechseler";
return activeSource;
}
//Getters, Setters und SupportMethods
public void setCD(CD _loadedCD) {
@ -175,8 +180,10 @@ public class CDPlayer implements Device {
this.infoText=this.getClass().getSimpleName()+": Item->"+actualPlayTrack+" from Album->"+this.loadedCD.getAlbumName()+" running.";
}
public CD getCD() {
return this.loadedCD;
}
}

19
src/main/java/device/cdPlayer/CDWechseler.java

@ -0,0 +1,19 @@
package device.cdPlayer;
import java.util.List;
public class CDWechseler {
private List<CD>CDList;
private boolean running=false;
public boolean isRunning() {
return running;
}
public void activate() {
this.running = true;
}
}

16
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -364,4 +364,20 @@ class CDPlayerTest {
);
}
@ParameterizedTest
@MethodSource("changePlaySourceData")
void changePlaySourceTest(String testName,String cases, CDPlayer _cdPlayer) {
String returnVal=_cdPlayer.changePlaySource();
assertThat(returnVal).describedAs(testName).isEqualTo("CDWechseler");
}
static Stream<Arguments> changePlaySourceData () {
CDPlayer cdPlayer1 = new CDPlayer();
return Stream.of(
Arguments.of("[changePlaySource() by activeSource=CDDrive ] => shouldReturnCDWechseler","Case1", cdPlayer1)
);
}
}
Loading…
Cancel
Save