Browse Source

Merge pull request 'feature-pr-cdPlayerQuieterTest' (#12) from feature-pr-cdPlayerQuieterTest into master

feature-pr-organization
Jan Ortner 3 years ago
parent
commit
bb8d595525
  1. 14
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 57
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -21,17 +21,25 @@ public class CDPlayer implements Device {
@Override @Override
public void louder() { public void louder() {
if(volume < 100) {
volume += 1;
} else {
volume = 100;
}
} }
@Override @Override
public void quieter() { public void quieter() {
if(volume > 0) {
volume -= 1;
} else {
volume = 0;
}
} }
@Override @Override
public int getVolume() { public int getVolume() {
return 0;
return volume;
} }
@Override @Override

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

@ -1,47 +1,52 @@
package device.cdPlayer; package device.cdPlayer;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(MockitoExtension.class)
class CDPlayerTest { class CDPlayerTest {
/*
@Test
void louder() {
}
@Test
void quieter() {
@ParameterizedTest
@MethodSource("quieterTestData")
void quieterTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, int expectedResult) {
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.quieter();
} }
@Test
void getVolume() {
if(testDirection.equals("VolumeDecreased")){
for (int i = 0; i < 20; i++) {
_cdPlayer.louder();
} }
@Test
void next() {
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.quieter();
} }
@Test
void prev() {
assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(expectedResult);
} }
if(testDirection.equals("VolumeHasNotChanged")){
assertThat(_cdPlayer.getVolume()).describedAs(testName).isEqualTo(expectedResult);
}if(testDirection.equals("VolumeNotIncreased")){
@Test
void getInfoText() {
assertThat(_cdPlayer.getVolume()).describedAs(testName).isNotEqualTo(expectedResult);
} }
@Test
void getOptions() {
}
@Test
void chooseOption() {
} }
@Test
void play() {
static Stream<Arguments> quieterTestData () {
CDPlayer cdPlayer=new CDPlayer();
return Stream.of(
Arguments.of("[getVolume() after 20x quieter() starting by 20] => VolumeHasDecreased","VolumeDecreased", cdPlayer, 19, 1),
Arguments.of("[getVolume() after 20x quieter() starting by 0] => VolumeHasNotChanged","VolumeHasNotChanged" ,cdPlayer,20,0),
Arguments.of("[getVolume() after 5x quieter() starting by 0] => VolumeNotIncreased","VolumeNotIncreased", cdPlayer,5,5)
);
} }
*/
} }
Loading…
Cancel
Save