Browse Source

Method changeToNextCD of CDPlayer tested checking the effect2 -> loadedCDShouldNotHaveTheSameIdAsPrev.

feature-pr-jacksonsNewFeature
JPANZO 3 years ago
parent
commit
b307012590
  1. 16
      src/main/java/device/cdPlayer/CD.java
  2. 2
      src/main/java/device/cdPlayer/CDPlayer.java
  3. 29
      src/test/java/device/cdPlayer/CDPlayerTest.java

16
src/main/java/device/cdPlayer/CD.java

@ -4,6 +4,7 @@ public class CD {
private String format;
private String albumName;
private String[] playList;
private String id;
public CD() {}
@ -16,6 +17,13 @@ public class CD {
this.playList = playList;
}
public CD(String format, String albumName, String[] playList, String id) {
this.format = format;
this.albumName = albumName;
this.playList = playList;
this.id = id;
}
public String getFormat() {
return format;
}
@ -39,4 +47,12 @@ public class CD {
public void setAlbumName(String albumName) {
this.albumName = albumName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

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

@ -152,7 +152,7 @@ public class CDPlayer implements Device {
throw new MaxCapacityExceededException();
}
cdWechseler.loadOneCD(cd,index);
System.out.println(index);
this.loadedCD=cdWechseler.getCDList()[0];
}
public void changeToNextCD(){
if(activeSource.equals("CDDrive")){

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

@ -441,21 +441,40 @@ class CDPlayerTest {
CD nextCD=_cdPlayer.getCD();
assertThat(nextCD).describedAs(testName).isNotEqualTo(null);
}
if(cases.equals("Case3")) {
CD actualCD=_cdPlayer.getCD();
System.out.println("loadedCD_id:"+actualCD.getId());
_cdPlayer.changeToNextCD();
CD nextCD=_cdPlayer.getCD();
System.out.println("nextCD_id:"+nextCD.getId());
/*System.out.println("loadedCD_id:"+_cdPlayer.getCD().getId());
System.out.println("actualCD_id:"+_cdPlayer.getCdWechseler().getCDList()[0].getId());
System.out.println("nextCD_id:"+_cdPlayer.getCdWechseler().getCDList()[1].getId());*/
//System.out.println("nextCD_id:"+nextCD.getId());
assertThat(nextCD.getId()==actualCD.getId()).describedAs(testName).isNotEqualTo(true);
}
}
static Stream<Arguments> changeToNextCDData () {
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
CD audioCD1=new CD("Audio","PopMusic",audioPlayList,"XAc20044");
CD audioCD2=new CD("Audio","RockMusic",audioPlayList,"BLXPP78");
CDPlayer cdPlayer1 = new CDPlayer();
CDPlayer cdPlayer2 = new CDPlayer();
cdPlayer2.changePlaySource();
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
CD audioCD1=new CD("Audio",audioPlayList);
cdPlayer2.loadCDWechseler(audioCD1,0);
cdPlayer2.loadCDWechseler(audioCD1,1);
cdPlayer2.loadCDWechseler(audioCD2,1);
CDPlayer cdPlayer3 = new CDPlayer();
cdPlayer3.changePlaySource();
cdPlayer3.loadCDWechseler(audioCD1,0);
cdPlayer3.loadCDWechseler(audioCD2,1);
return Stream.of(
Arguments.of("[changeToNextCD() by CDWechselerNotSelected ] => shouldThrowAnException", "Case1", cdPlayer1,new ChangeCDOnlyOnCDWechselerException()),
Arguments.of("[changeToNextCD() checking the effect ] => loadedCDShouldNotReturnNull", "Case2", cdPlayer2,null)
Arguments.of("[changeToNextCD() checking the effect ] => loadedCDShouldNotReturnNull", "Case2", cdPlayer2,null),
Arguments.of("[changeToNextCD() checking the effect 2 ] => loadedCDShouldNotHaveTheSameIdAsPrev", "Case3", cdPlayer3,null)
);
}

Loading…
Cancel
Save