Browse Source

getOptions from CDPlayer tested on ArrayLengthGreaterThen 0.

feature-pr-cdPlayerGetOptions
JPANZO 3 years ago
parent
commit
6c5989e12f
  1. 10
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 10
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -2,6 +2,8 @@ package device.cdPlayer;
import device.Device;
import device.cdPlayer.exceptions.*;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -69,7 +71,13 @@ public class CDPlayer implements Device {
@Override
public String[] getOptions() {
return new String[]{};
Method[] methods=this.getClass().getDeclaredMethods();
String[] outMethods=new String[methods.length];
for (int i = 0; i <methods.length ; i++) {
outMethods[i]=methods[i].getName();
}
return outMethods;
}
@Override

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

@ -232,12 +232,18 @@ class CDPlayerTest {
@ParameterizedTest
@MethodSource("getOptionsTestData")
void getOptionsTest(String testName,String testDirection, CDPlayer _cdPlayer, String expectedResult){
assertThat(_cdPlayer.getOptions()).describedAs(testName).isNotEqualTo(null);
if(testDirection.equals("ReturnValueNotNull")) {
assertThat(_cdPlayer.getOptions()).describedAs(testName).isNotEqualTo(null);
}
if(testDirection.equals("ArrayLengthGreaterThen0")) {
assertThat(_cdPlayer.getOptions().length).describedAs(testName).isNotEqualTo(0);
}
}
static Stream<Arguments> getOptionsTestData () {
CDPlayer cdPlayer1 = new CDPlayer();
return Stream.of(
Arguments.of("[getOptions(): shouldNotReturnsNull] => ReturnValueNotNull", "ReturnValueNotNull", cdPlayer1,null)
Arguments.of("[getOptions(): shouldNotReturnNull] => ReturnValueNotNull", "ReturnValueNotNull", cdPlayer1,null),
Arguments.of("[getOptions(): shouldReturnAnArrayWithLengthGreaterThen0] => ArrayLengthGreaterThen0", "ArrayLengthGreaterThen0", cdPlayer1,null)
);
}

Loading…
Cancel
Save