Browse Source

Method getInfoText of CDPlayer tested on MessageShouldContainInfoAboutAlbum.

feature-pr-RadioPlayer-getOptions
JPANZO 3 years ago
parent
commit
c5c7ea8c95
  1. 9
      src/main/java/device/cdPlayer/CD.java
  2. 7
      src/main/java/device/cdPlayer/CDPlayer.java
  3. 11
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -2,6 +2,7 @@ package device.cdPlayer;
public class CD { public class CD {
private String format; private String format;
private String albumName;
private String[] playList; private String[] playList;
public CD() {} public CD() {}
@ -30,4 +31,12 @@ public class CD {
public void setPlayList(String[] playList) { public void setPlayList(String[] playList) {
this.playList = playList; this.playList = playList;
} }
public String getAlbumName() {
return albumName;
}
public void setAlbumName(String albumName) {
this.albumName = albumName;
}
} }

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

@ -161,9 +161,12 @@ public class CDPlayer implements Device {
return actualPlayTrack; return actualPlayTrack;
} }
public void setInfoText(String infoText) {
this.infoText=infoText;
public void setInfoText() {
this.infoText="CDPlayer: Item->"+actualPlayTrack+" from Album->"+this.loadedCD.getAlbumName()+" running.";
} }
public CD getCD() {
return this.loadedCD;
}
} }

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

@ -296,6 +296,11 @@ class CDPlayerTest {
} }
assertThat(containsInfoOfActualPlayTrack).describedAs(testName).isEqualTo(true); assertThat(containsInfoOfActualPlayTrack).describedAs(testName).isEqualTo(true);
} }
if(cases.equals("Case4")) {
String albumName= _cdPlayer.getCD().getAlbumName();
assertThat(_cdPlayer.getInfoText().contains(albumName)).describedAs(testName).isEqualTo(true);
}
} }
static Stream<Arguments> getInfoTestData () { static Stream<Arguments> getInfoTestData () {
CDPlayer cdPlayer1 = new CDPlayer(); CDPlayer cdPlayer1 = new CDPlayer();
@ -303,16 +308,18 @@ class CDPlayerTest {
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"}; String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
//some CDs //some CDs
CD audioCD1=new CD("Audio",audioPlayList); CD audioCD1=new CD("Audio",audioPlayList);
audioCD1.setAlbumName("Love Songs");
CDPlayer cdPlayer2 = new CDPlayer(); CDPlayer cdPlayer2 = new CDPlayer();
cdPlayer2.tapOnCdFlap(); cdPlayer2.tapOnCdFlap();
cdPlayer2.setCD(audioCD1); cdPlayer2.setCD(audioCD1);
cdPlayer2.tapOnCdFlap(); cdPlayer2.tapOnCdFlap();
cdPlayer2.setInfoText("CDPlayer: Item->"+cdPlayer2.getActualPlayTrack()+" from Album->"+"AlbumName"+" running.");
cdPlayer2.setInfoText();
return Stream.of( return Stream.of(
Arguments.of("[getInfoText() by infoText=null ] => shouldThrowReturnValueNullException","Case1", cdPlayer1,new ReturnValueNullException(),""), Arguments.of("[getInfoText() by infoText=null ] => shouldThrowReturnValueNullException","Case1", cdPlayer1,new ReturnValueNullException(),""),
Arguments.of("[getInfoText() by infoText=null ] => ExceptionShouldReturnAMessage","Case2",cdPlayer1,new ReturnValueNullException(),"Method should not return a Null-Value."), Arguments.of("[getInfoText() by infoText=null ] => ExceptionShouldReturnAMessage","Case2",cdPlayer1,new ReturnValueNullException(),"Method should not return a Null-Value."),
Arguments.of("[getInfoText() by infoText=Message ] => MessageShouldContainInfoOfActualPlayTrack","Case3",cdPlayer2,null,"")
Arguments.of("[getInfoText() by infoText=Message ] => MessageShouldContainInfoOfActualPlayTrack","Case3",cdPlayer2,null,""),
Arguments.of("[getInfoText() by infoText=Message ] => MessageShouldContainInfoAboutAlbum","Case4",cdPlayer2,null,"")
); );
} }
Loading…
Cancel
Save