|
|
@ -1,7 +1,9 @@ |
|
|
|
import device.Device; |
|
|
|
import device.cdPlayer.CDPlayer; |
|
|
|
import device.cdPlayer.exceptions.NegativeInputException; |
|
|
|
import device.radioPlayer.RadioPlayer; |
|
|
|
import device.usbPlayer.UsbPlayer; |
|
|
|
import exception.NoItemEvenAllPreconditionAreMet; |
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
@ -100,15 +102,25 @@ class BordComputerTest { |
|
|
|
bordComputer.meetAllPreconditionForPlay(); |
|
|
|
assertThat(bordComputer.play()).describedAs(testName).isNotEqualTo(null); |
|
|
|
} |
|
|
|
if(testCase.equals("Case4")) { |
|
|
|
Exception newException = assertThrows(NoItemEvenAllPreconditionAreMet.class, () -> bordComputer.play()); |
|
|
|
assertEquals(NoItemEvenAllPreconditionAreMet.class, newException.getClass()); |
|
|
|
assertEquals(newException.getMessage(), "No Item returned even all preconditions are met."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> playDate()throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { |
|
|
|
BordComputer bordComputer = new BordComputer(); |
|
|
|
bordComputer.readConfig(); |
|
|
|
|
|
|
|
BordComputer bordComputer2 = new BordComputer(); |
|
|
|
bordComputer2.readConfig(); |
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
Arguments.of("[CDPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case1",bordComputer,"CDPlayer"), |
|
|
|
Arguments.of("[RadioPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case2",bordComputer,"RadioPlayer"), |
|
|
|
Arguments.of("[UsbPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case3",bordComputer,"UsbPlayer") |
|
|
|
Arguments.of("[UsbPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case3",bordComputer,"UsbPlayer"), |
|
|
|
Arguments.of("[CDPlayer-> play(): without fulfilling preconditions] => ShouldReturnAnException","Case4",bordComputer2,"CDPlayer") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|