mirror of
https://github.com/wahyd4/RobotSimulator.git
synced 2026-08-08 21:06:38 +10:00
85 lines
2.4 KiB
Java
85 lines
2.4 KiB
Java
package au.com.seek.domain;
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import static org.hamcrest.CoreMatchers.equalTo;
|
|
import static org.hamcrest.core.Is.is;
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
public class DirectionTest {
|
|
|
|
@Test
|
|
public void should_return_new_direction_when_do_turn_left() throws Exception {
|
|
|
|
assertThat(Direction.NORTH.turnLeft(), is(Direction.WEST));
|
|
|
|
assertThat(Direction.WEST.turnLeft(), is(Direction.SOUTH));
|
|
|
|
assertThat(Direction.SOUTH.turnLeft(), is(Direction.EAST));
|
|
|
|
assertThat(Direction.EAST.turnLeft(), is(Direction.NORTH));
|
|
}
|
|
|
|
@Test
|
|
public void should_return_new_direction_when_do_turn_right() throws Exception {
|
|
|
|
assertThat(Direction.NORTH.turnRight(), is(Direction.EAST));
|
|
|
|
assertThat(Direction.EAST.turnRight(), is(Direction.SOUTH));
|
|
|
|
assertThat(Direction.SOUTH.turnRight(), is(Direction.WEST));
|
|
|
|
assertThat(Direction.WEST.turnRight(), is(Direction.NORTH));
|
|
}
|
|
|
|
|
|
@Test
|
|
public void should_return_step_value_on_x_axis() throws Exception {
|
|
|
|
assertThat(Direction.NORTH.stepValueOnXAxis(), is(0));
|
|
|
|
assertThat(Direction.EAST.stepValueOnXAxis(), is(1));
|
|
|
|
assertThat(Direction.SOUTH.stepValueOnXAxis(), is(0));
|
|
|
|
assertThat(Direction.WEST.stepValueOnXAxis(), is(-1));
|
|
}
|
|
|
|
@Test
|
|
public void should_return_step_value_on_y_axis() throws Exception {
|
|
|
|
assertThat(Direction.NORTH.stepValueOnYAxis(), is(1));
|
|
|
|
assertThat(Direction.EAST.stepValueOnYAxis(), is(0));
|
|
|
|
assertThat(Direction.SOUTH.stepValueOnYAxis(), is(-1));
|
|
|
|
assertThat(Direction.WEST.stepValueOnYAxis(), is(0));
|
|
}
|
|
|
|
@Test
|
|
public void should_return_direction_string_as_enum() throws Exception {
|
|
|
|
assertThat(Direction.NORTH.toString(), equalTo("NORTH"));
|
|
|
|
assertThat(Direction.WEST.toString(), equalTo("WEST"));
|
|
|
|
assertThat(Direction.SOUTH.toString(), equalTo("SOUTH"));
|
|
|
|
assertThat(Direction.EAST.toString(), equalTo("EAST"));
|
|
}
|
|
|
|
@Test
|
|
public void should_return_all_the_values_of_direction() throws Exception {
|
|
Direction[] directions = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
|
assertThat(Direction.values(), equalTo(directions));
|
|
}
|
|
|
|
@Test
|
|
public void test_value_of() throws Exception {
|
|
Direction east = Direction.valueOf("EAST");
|
|
assertThat(east, is(Direction.EAST));
|
|
}
|
|
}
|