forked from next-step/java-racingcar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCarTest.java
41 lines (35 loc) · 879 Bytes
/
CarTest.java
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
34
35
36
37
38
39
40
41
package racing;
import org.junit.jupiter.api.Test;
import racing.entity.Car;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CarTest {
@Test
void carMoves() {
Car car = new Car("Car");
car.move();
assertEquals(1, car.getPosition());
}
@Test
void carDoesNotMove() {
Car car = new Car("CarzCar") {
@Override
public void move() {
if (!canMove()) {
position = 0;
}
}
};
car.move();
assertEquals(0, car.getPosition());
}
@Test
void carNameIsSetCorrectly() {
Car car = new Car("Car");
assertEquals("Car", car.getName());
}
@Test
void carInitialPositionIsZero() {
Car car = new Car("Car");
assertEquals(0, car.getPosition());
}
}