Browse Source

Merge branch 'feature-pr-cdPlayerLouderTest' into feature-pr-organization

# Conflicts:
#	src/main/java/device/cdPlayer/CDPlayer.java
#	src/test/java/device/cdPlayer/CDPlayerTest.java
feature-pr-organization
JPANZO 3 years ago
parent
commit
21a6010115
  1. 24
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -12,7 +12,6 @@ import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(MockitoExtension.class)
class CDPlayerTest {
@ -78,11 +77,34 @@ class CDPlayerTest {
cdPlayer9.tapOnCdFlap();
cdPlayer9.setCD(audioCD3);
cdPlayer9.tapOnCdFlap();
@ParameterizedTest
@MethodSource("louderTestData")
void louderTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, int expectedResult) {
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.louder();
}
if(testDirection.equals("VolumeIncreased")){
assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(expectedResult);
}
if(testDirection.equals("VolumeHasChanged")){
assertThat(_cdPlayer.getVolume()).describedAs(testName).isNotEqualTo(expectedResult);
}if(testDirection.equals("VolumeNotDecreased")){
assertThat(_cdPlayer.getVolume()).describedAs(testName).isNotEqualTo(expectedResult);
}
}
CDPlayer cdPlayer10=new CDPlayer();
cdPlayer10.tapOnCdFlap();
cdPlayer10.setCD(audioCD4);
cdPlayer10.tapOnCdFlap();
static Stream<Arguments> louderTestData () {
CDPlayer cdPlayer=new CDPlayer();
return Stream.of(
Arguments.of("[getVolume() after 20x louder() ] => VolumeIncreased","VolumeIncreased", cdPlayer, 20, 20),
Arguments.of("[getVolume() after 2x louder() ] => VolumeHasChanged","VolumeHasChanged" ,cdPlayer,2,0),
Arguments.of("[getVolume() after 5x louder() ] => VolumeDecreased","VolumeNotDecreased", cdPlayer,5,-5)
);
}
return Stream.of(
Arguments.of("[CdFlap=isClosed , CdDriveContent=>isEmpty] => NoCD", cdPlayer1, new NoCDException(), "CD must be set."),

Loading…
Cancel
Save