Browse Source

Method changePlaySource of CDPlayer tested on activeSource=CDWechseler -> shouldReturnCDDrive.

feature-pr-BordComputer-setDevices
JPANZO 3 years ago
parent
commit
7faf0d78e2
  1. 5
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 17
      src/test/java/device/cdPlayer/CDPlayerTest.java

5
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;
}

17
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<Arguments> 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)
);
}

Loading…
Cancel
Save