Browse Source

Method chooseItem of CDPlayer tested on notSetCD.

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

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

@ -18,7 +18,7 @@ public class CDPlayer implements Device {
private List<String> supportedFormats = new ArrayList<String>(Arrays.asList(new String[] {"Audio","MP3","WMA","AAC"})); private List<String> supportedFormats = new ArrayList<String>(Arrays.asList(new String[] {"Audio","MP3","WMA","AAC"}));
private String actualPlayTrack=""; private String actualPlayTrack="";
private CD loadedCD;
private CD loadedCD=null;
@Override @Override
public void louder() { public void louder() {
@ -86,6 +86,9 @@ public class CDPlayer implements Device {
@Override @Override
public String chooseItem(int itemNr) { public String chooseItem(int itemNr) {
if(this.loadedCD==null){
throw new ReturnValueNullException();
}
return null; return null;
} }

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

@ -327,4 +327,17 @@ class CDPlayerTest {
); );
} }
@ParameterizedTest
@MethodSource("chooseItemTestData")
void chooseItemTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception , String expectedResult) {
Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.chooseItem(1));
assertEquals(ReturnValueNullException.class, newException.getClass());
}
static Stream<Arguments> chooseItemTestData () {
CDPlayer cdPlayer1 = new CDPlayer();
return Stream.of(
Arguments.of("[chooseItem() by notSetCD ] => shouldThrowReturnValueNullException","Case1", cdPlayer1,new ReturnValueNullException(),"")
);
}
} }
Loading…
Cancel
Save