Browse Source

Tests for CDPlayer-Method [Play] created.

feature-pr-cdPlayerPlayTest
JPANZO 3 years ago
parent
commit
ce4ab1fbd4
  1. 6
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 110
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -65,7 +65,7 @@ public class CDPlayer implements Device {
return null;
}
//Getters und Setters
//Getters, Setters und SupportMethods
public void setCD(CD _loadedCD) {
loadedCD=_loadedCD;
this.setCdDriveContent();
@ -76,4 +76,8 @@ public class CDPlayer implements Device {
CdDriveContent = 1;
}
public void tapOnCdFlap(){
this.CdFlap+=1;
}
}

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

@ -1,47 +1,101 @@
package device.cdPlayer;
import device.cdPlayer.exceptions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(MockitoExtension.class)
class CDPlayerTest {
/*
@Test
void louder() {
}
@Test
void quieter() {
@ParameterizedTest
@MethodSource("playTestData")
void play(String testName, CDPlayer _cdPlayer,Exception exception , String expectedResult) {
if(exception!=null){
Exception newException=assertThrows(exception.getClass(),()->_cdPlayer.play());
assertEquals(expectedResult, newException.getMessage());
}else{
assertThat(_cdPlayer.play()).describedAs(testName).isEqualTo(expectedResult);
}
@Test
void getVolume() {
}
static Stream<Arguments> playTestData () {
//some PlayLists
String[] videoPlayList=new String[]{"Video 01","Video 02","Video 03","Video 04","Video 05"};
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
//some CDs
CD videoCD1=new CD("DVD",videoPlayList);
CD videoCD2=new CD("Blue-ray",videoPlayList);
CD audioCD1=new CD("Audio",audioPlayList);
CD audioCD2=new CD("MP3",audioPlayList);
CD audioCD3=new CD("WMA",audioPlayList);
CD audioCD4=new CD("AAC",audioPlayList);
@Test
void next() {
}
//some CDPlayers
CDPlayer cdPlayer1=new CDPlayer();
@Test
void prev() {
}
CDPlayer cdPlayer2=new CDPlayer();
cdPlayer2.tapOnCdFlap();
cdPlayer2.tapOnCdFlap();
@Test
void getInfoText() {
}
CDPlayer cdPlayer3=new CDPlayer();
cdPlayer3.tapOnCdFlap();
@Test
void getOptions() {
}
CDPlayer cdPlayer4=new CDPlayer();
cdPlayer4.tapOnCdFlap();
cdPlayer4.setCD(videoCD1);
@Test
void chooseOption() {
}
//===================================
CDPlayer cdPlayer5=new CDPlayer();
cdPlayer5.tapOnCdFlap();
cdPlayer5.setCD(videoCD1);
cdPlayer5.tapOnCdFlap();
@Test
void play() {
}
CDPlayer cdPlayer6=new CDPlayer();
cdPlayer6.tapOnCdFlap();
cdPlayer6.setCD(videoCD2);
cdPlayer6.tapOnCdFlap();
//===================================
CDPlayer cdPlayer7=new CDPlayer();
cdPlayer7.tapOnCdFlap();
cdPlayer7.setCD(audioCD1);
cdPlayer7.tapOnCdFlap();
CDPlayer cdPlayer8=new CDPlayer();
cdPlayer8.tapOnCdFlap();
cdPlayer8.setCD(audioCD2);
cdPlayer8.tapOnCdFlap();
*/
CDPlayer cdPlayer9=new CDPlayer();
cdPlayer9.tapOnCdFlap();
cdPlayer9.setCD(audioCD3);
cdPlayer9.tapOnCdFlap();
CDPlayer cdPlayer10=new CDPlayer();
cdPlayer10.tapOnCdFlap();
cdPlayer10.setCD(audioCD4);
cdPlayer10.tapOnCdFlap();
return Stream.of(
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isEmpty] => NoCD", cdPlayer1, new NoCDException(), "CD must be set."),
Arguments.of("[CdFlap has been Opened and Closed, CdDriveContent=>isEmpty] => NoCD", cdPlayer2,new NoCDException(),"CD must be set."),
Arguments.of("[CdFlap=isOpen , CdDriveContent=>isEmpty] => CdFlapIsOpen", cdPlayer3,new CdFlapIsOpenException(),"Cd Flap must be closed."),
Arguments.of("[CdFlap=isOpen , CdDriveContent=>isSet] => CdFlapIsOpen", cdPlayer4,new CdFlapIsOpenException(),"Cd Flap must be closed."),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>DVD] => FormatNotSupported",cdPlayer5,new FormatNotSupportedException(),"Cd-Format not supported."),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>Blue-ray] => FormatNotSupported",cdPlayer6, new FormatNotSupportedException(),"Cd-Format not supported."),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>Audio] => AllConditionsForPlayMet", cdPlayer7,null,"AllConditionsForPlayMet"),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>MP3] => AllConditionsForPlayMet", cdPlayer8,null,"AllConditionsForPlayMet"),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>WMA] => AllConditionsForPlayMet", cdPlayer9,null,"AllConditionsForPlayMet"),
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isSet, CdFormat=>AAC] => AllConditionsForPlayMet", cdPlayer10,null,"AllConditionsForPlayMet")
);
}
}
Loading…
Cancel
Save