|
|
@ -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."), |
|
|
|