Browse Source

Method loadCDWechseler of CDPlayer tested on leadingFirstCD -> CDListOfCDWechselerShouldHaveLength1.

feature-pr-BordComputer-setDevices
JPANZO 3 years ago
parent
commit
e6741fd092
  1. 6
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 9
      src/main/java/device/cdPlayer/CDWechseler.java
  3. 9
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -148,6 +148,7 @@ public class CDPlayer implements Device {
if(!(this.supportedFormats.contains(cd.getFormat()))){ if(!(this.supportedFormats.contains(cd.getFormat()))){
throw new FormatNotSupportedException(); throw new FormatNotSupportedException();
} }
cdWechseler.loadOneCD(cd);
} }
//Getters, Setters und SupportMethods //Getters, Setters und SupportMethods
@ -197,6 +198,7 @@ public class CDPlayer implements Device {
return this.loadedCD; return this.loadedCD;
} }
public CDWechseler getCdWechseler() {
return cdWechseler;
}
} }

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

@ -1,9 +1,10 @@
package device.cdPlayer; package device.cdPlayer;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CDWechseler { public class CDWechseler {
private List<CD>CDList;
private List<CD>CDList=new ArrayList<>();
private boolean running=false; private boolean running=false;
@ -15,5 +16,11 @@ public class CDWechseler {
this.running = true; this.running = true;
} }
public List<CD> getCDList() {
return CDList;
}
public void loadOneCD(CD cd){
CDList.add(cd);
}
} }

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

@ -401,6 +401,12 @@ class CDPlayerTest {
Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.loadCDWechseler(cd)); Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.loadCDWechseler(cd));
assertEquals(FormatNotSupportedException.class, newException.getClass()); assertEquals(FormatNotSupportedException.class, newException.getClass());
} }
if(cases.equals("Case3")) {
_cdPlayer.changePlaySource();
_cdPlayer.loadCDWechseler(cd);
int length=_cdPlayer.getCdWechseler().getCDList().size();
assertThat(length).describedAs(testName).isEqualTo(1);
}
} }
static Stream<Arguments> loadCDWechselerData () { static Stream<Arguments> loadCDWechselerData () {
CDPlayer cdPlayer1 = new CDPlayer(); CDPlayer cdPlayer1 = new CDPlayer();
@ -411,7 +417,8 @@ class CDPlayerTest {
CD DVD=new CD("DVD",videoPlayList); CD DVD=new CD("DVD",videoPlayList);
return Stream.of( return Stream.of(
Arguments.of("[loadCDWechseler() by notRunning=CDWechseler ] => shouldThrowAnException", "Case1", cdPlayer1,audioCD1,new CDWechselerNotRunningException()), Arguments.of("[loadCDWechseler() by notRunning=CDWechseler ] => shouldThrowAnException", "Case1", cdPlayer1,audioCD1,new CDWechselerNotRunningException()),
Arguments.of("[loadCDWechseler() by WrongCDFormat ] => shouldThrowAnException", "Case2", cdPlayer1,DVD,new FormatNotSupportedException())
Arguments.of("[loadCDWechseler() by WrongCDFormat ] => shouldThrowAnException", "Case2", cdPlayer1,DVD,new FormatNotSupportedException()),
Arguments.of("[loadCDWechseler() by leadingFirstCD ] => CDListOfCDWechselerShouldHaveLength1", "Case3", cdPlayer1,audioCD1,null)
); );
} }

Loading…
Cancel
Save