diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index 90a1f92..724c2b4 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -158,7 +158,7 @@ public class CDPlayer implements Device { if(activeSource.equals("CDDrive")){ throw new ChangeCDOnlyOnCDWechselerException(); } - + this.loadedCD=cdWechseler.getCDList()[1]; } //Getters, Setters und SupportMethods diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index add6d31..20cbc8d 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -431,14 +431,31 @@ class CDPlayerTest { @ParameterizedTest @MethodSource("changeToNextCDData") void changeToNextCDTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception) { + if(cases.equals("Case1")) { Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.changeToNextCD()); 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 changeToNextCDData () { 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( - 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) ); }