sahar
3 years ago
5 changed files with 338 additions and 63 deletions
-
38src/main/java/device/cdPlayer/CDPlayer.java
-
110src/main/java/device/usbPlayer/UsbPlayer.java
-
110src/test/java/device/cdPlayer/CDPlayerTest.java
-
43src/test/java/device/radioPlayer/RadioPlayerTest.java
-
100src/test/java/device/usbPlayer/UsbPlayerTest.java
@ -1,55 +1,89 @@ |
|||||
package device.usbPlayer; |
package device.usbPlayer; |
||||
|
|
||||
import org.junit.jupiter.api.Test; |
|
||||
|
import org.junit.jupiter.params.ParameterizedTest; |
||||
|
import org.junit.jupiter.params.provider.Arguments; |
||||
|
import org.junit.jupiter.params.provider.MethodSource; |
||||
|
import java.util.stream.Stream; |
||||
|
import java.util.ArrayList; |
||||
|
|
||||
import static org.junit.jupiter.api.Assertions.*; |
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
|
||||
class UsbPlayerTest { |
class UsbPlayerTest { |
||||
|
|
||||
UsbPlayer up = new UsbPlayer(); |
UsbPlayer up = new UsbPlayer(); |
||||
|
|
||||
|
|
||||
@Test |
|
||||
void louder_test() { |
|
||||
up.setLautstaerke(40); |
|
||||
up.louder(); |
|
||||
assertThat(up.getLautstaerke()).isEqualTo(41); |
|
||||
|
@ParameterizedTest |
||||
|
@MethodSource("PlayOptions") |
||||
|
void playTest(String testName, UsbPlayer inputPlay, String expectedResult) { |
||||
|
String playState = inputPlay.play(); |
||||
|
assertThat(playState).describedAs(testName).isEqualTo(expectedResult); |
||||
} |
} |
||||
|
|
||||
@Test |
|
||||
void quieter_test() { |
|
||||
up.setLautstaerke(40); |
|
||||
up.quieter(); |
|
||||
assertThat(up.getLautstaerke()).isEqualTo(39); |
|
||||
} |
|
||||
/* |
|
||||
@Test |
|
||||
void getVolume() { |
|
||||
} |
|
||||
|
static Stream<Arguments> PlayOptions() { |
||||
|
UsbPlayer up1 = new UsbPlayer(); |
||||
|
UsbPlayer up8 = new UsbPlayer(); |
||||
|
up8.setPlayTrack(""); |
||||
|
UsbPlayer up2 = new UsbPlayer(); |
||||
|
ArrayList<String> l = new ArrayList<String>(); |
||||
|
l.add("a.mp3"); |
||||
|
l.add("b.mp3"); |
||||
|
l.add("c.gif"); |
||||
|
up2.setPlaylist(l); |
||||
|
UsbPlayer up3 = new UsbPlayer(); |
||||
|
ArrayList<String> Pl = new ArrayList<String>(); |
||||
|
up3.setPlaylist(Pl); |
||||
|
UsbPlayer up6 = new UsbPlayer(); |
||||
|
up6.setDefect(true); |
||||
|
UsbPlayer up7 = new UsbPlayer(); |
||||
|
up7.setConnected(false); |
||||
|
|
||||
@Test |
|
||||
void next() { |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
void prev() { |
|
||||
|
return Stream.of( |
||||
|
Arguments.of("All right : ", up1, "USB : connected,working,have a list,Audio,point to a track."), |
||||
|
Arguments.of("No first Track : ", up8, "USB : connected,working,have a list,Audio,doesn't point to a track."), |
||||
|
Arguments.of("No Audio Files : ", up2, "USB : connected,working,have a list,not Audio."), |
||||
|
Arguments.of("No list of tracks : ", up3, "USB : connected,working,have no list."), |
||||
|
Arguments.of("connected , not working : ", up6, "USB : connected,not working."), |
||||
|
Arguments.of("not connected : ", up7, "not connected.")); |
||||
} |
} |
||||
|
|
||||
@Test |
|
||||
void getInfoText() { |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
void getOptions() { |
|
||||
|
@ParameterizedTest |
||||
|
@MethodSource("louderOptions") |
||||
|
void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
||||
|
int volumeNum = inputPlay.getLautstaerke(); |
||||
|
assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); |
||||
|
} |
||||
|
|
||||
|
static Stream<Arguments> louderOptions() { |
||||
|
UsbPlayer up11 = new UsbPlayer(); |
||||
|
up11.louder(); |
||||
|
UsbPlayer up22 = new UsbPlayer(); |
||||
|
up22.setLautstaerke(100); |
||||
|
up22.louder(); |
||||
|
return Stream.of( |
||||
|
Arguments.of("Volume is : 1 ", up11, 1), |
||||
|
Arguments.of("Volume is : 100 ", up22, 100) |
||||
|
); |
||||
} |
} |
||||
|
|
||||
@Test |
|
||||
void chooseOption() { |
|
||||
|
@ParameterizedTest |
||||
|
@MethodSource("quieterOptions") |
||||
|
void quieterTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
||||
|
int volumeNum = inputPlay.getLautstaerke(); |
||||
|
assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); |
||||
} |
} |
||||
|
|
||||
@Test |
|
||||
void play() { |
|
||||
|
static Stream<Arguments> quieterOptions() { |
||||
|
UsbPlayer up1 = new UsbPlayer(); |
||||
|
up1.quieter(); |
||||
|
UsbPlayer up2 = new UsbPlayer(); |
||||
|
up2.setLautstaerke(10); |
||||
|
up2.quieter(); |
||||
|
return Stream.of( |
||||
|
Arguments.of("Volume must stay 0 ", up1, 0), |
||||
|
Arguments.of("Volume must be 9 ", up2, 9) |
||||
|
); |
||||
} |
} |
||||
*/ |
|
||||
|
|
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue