diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index 827d104..89f6ad9 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -133,7 +133,10 @@ public class CDPlayer implements Device { return null; } public String changePlaySource(){ - this.activeSource="CDWechseler"; + if(activeSource.equals("CDDrive")) { + this.activeSource = "CDWechseler"; + }else this.activeSource="CDDrive"; + return activeSource; } diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index 64ea048..f0ef16a 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -367,14 +367,25 @@ class CDPlayerTest { @ParameterizedTest @MethodSource("changePlaySourceData") void changePlaySourceTest(String testName,String cases, CDPlayer _cdPlayer) { - String returnVal=_cdPlayer.changePlaySource(); - assertThat(returnVal).describedAs(testName).isEqualTo("CDWechseler"); + + if(cases.equals("Case1")) { + String returnVal = _cdPlayer.changePlaySource(); + assertThat(returnVal).describedAs(testName).isEqualTo("CDWechseler"); + } + if(cases.equals("Case2")) { + String returnVal = _cdPlayer.changePlaySource(); + assertThat(returnVal).describedAs(testName).isEqualTo("CDDrive"); + } } static Stream changePlaySourceData () { CDPlayer cdPlayer1 = new CDPlayer(); + CDPlayer cdPlayer2 = new CDPlayer(); + cdPlayer2.changePlaySource(); + return Stream.of( - Arguments.of("[changePlaySource() by activeSource=CDDrive ] => shouldReturnCDWechseler","Case1", cdPlayer1) + Arguments.of("[changePlaySource() by activeSource=CDDrive ] => shouldReturnCDWechseler","Case1", cdPlayer1), + Arguments.of("[changePlaySource() by activeSource=CDWechseler ] => shouldReturnCDDrive","Case2", cdPlayer2) ); }