-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteControlCarTest.java
More file actions
33 lines (28 loc) · 1.18 KB
/
RemoteControlCarTest.java
File metadata and controls
33 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import org.junit.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class RemoteControlCarTest {
@Test
public void race() {
ProductionRemoteControlCar productionCar = new ProductionRemoteControlCar();
ExperimentalRemoteControlCar experimentalCar = new ExperimentalRemoteControlCar();
TestTrack.race(productionCar);
TestTrack.race(productionCar);
TestTrack.race(experimentalCar);
TestTrack.race(experimentalCar);
assertThat(experimentalCar.getDistanceTravelled() - productionCar.getDistanceTravelled()).isEqualTo(20);
}
@Test
public void rankCars() {
ProductionRemoteControlCar prc1 = new ProductionRemoteControlCar();
ProductionRemoteControlCar prc2 = new ProductionRemoteControlCar();
prc1.setNumberOfVictories(3);
prc2.setNumberOfVictories(2);
List<ProductionRemoteControlCar> rankings = TestTrack.getRankedCars(prc1, prc2);
assertThat(rankings.get(1)).isEqualTo(prc1);
}
@Test
public void ensureCarsAreComparables() {
assertThat(RemoteControlCar.class).isAssignableFrom(ProductionRemoteControlCar.class);
}
}