Browse Source

Method changeToNextCD of CDPlayer tested checking the effect -> loadedCDShouldNotReturnNull.

feature-pr-jacksonsNewFeature
JPANZO 3 years ago
parent
commit
f77ed10d41
  1. 2
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 19
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -158,7 +158,7 @@ public class CDPlayer implements Device {
if(activeSource.equals("CDDrive")){ if(activeSource.equals("CDDrive")){
throw new ChangeCDOnlyOnCDWechselerException(); throw new ChangeCDOnlyOnCDWechselerException();
} }
this.loadedCD=cdWechseler.getCDList()[1];
} }
//Getters, Setters und SupportMethods //Getters, Setters und SupportMethods

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

@ -431,14 +431,31 @@ class CDPlayerTest {
@ParameterizedTest @ParameterizedTest
@MethodSource("changeToNextCDData") @MethodSource("changeToNextCDData")
void changeToNextCDTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception) { void changeToNextCDTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception) {
if(cases.equals("Case1")) {
Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.changeToNextCD()); Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.changeToNextCD());
assertEquals(ChangeCDOnlyOnCDWechselerException.class, newException.getClass()); assertEquals(ChangeCDOnlyOnCDWechselerException.class, newException.getClass());
} }
if(cases.equals("Case2")) {
CD actualCD=_cdPlayer.getCD();
_cdPlayer.changeToNextCD();
CD nextCD=_cdPlayer.getCD();
assertThat(nextCD).describedAs(testName).isNotEqualTo(null);
}
}
static Stream<Arguments> changeToNextCDData () { static Stream<Arguments> changeToNextCDData () {
CDPlayer cdPlayer1 = new CDPlayer(); 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);
return Stream.of( return Stream.of(
Arguments.of("[changeToNextCD() by CDWechselerNotSelected ] => shouldThrowAnException", "Case1", cdPlayer1,new ChangeCDOnlyOnCDWechselerException())
Arguments.of("[changeToNextCD() by CDWechselerNotSelected ] => shouldThrowAnException", "Case1", cdPlayer1,new ChangeCDOnlyOnCDWechselerException()),
Arguments.of("[changeToNextCD() checking the effect ] => loadedCDShouldNotReturnNull", "Case2", cdPlayer2,null)
); );
} }

Loading…
Cancel
Save