package dungeonmania.mvp;
import dungeonmania.DungeonManiaController;
import dungeonmania.response.models.DungeonResponse;
Copyright By PowCoder代写 加微信 powcoder
import dungeonmania.response.models.EntityResponse;
import dungeonmania.util.Direction;
import dungeonmania.util.Position;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class MovementTest {
@Tag(“1-1”)
@DisplayName(“Test the player can move down”)
public void testMovementDown() {
DungeonManiaController dmc = new DungeonManiaController();
DungeonResponse initDungonRes = dmc.newGame(
“d_movementTest_testMovementDown”, “c_movementTest_testMovementDown”);
EntityResponse initPlayer = TestUtils.getPlayer(initDungonRes).get();
// create the expected result
EntityResponse expectedPlayer = new EntityResponse(initPlayer.getId(), initPlayer.getType(),
new Position(1, 2), false);
// move player downward
DungeonResponse actualDungonRes = dmc.tick(Direction.DOWN);
EntityResponse actualPlayer = TestUtils.getPlayer(actualDungonRes).get();
// assert after movement
assertTrue(TestUtils.entityResponsesEqual(expectedPlayer, actualPlayer));
@Tag(“1-2”)
@DisplayName(“Test the player can move up”)
public void testMovementUp() {
DungeonManiaController dmc = new DungeonManiaController();
DungeonResponse initDungonRes = dmc.newGame(“d_movementTest_testMovementUp”, “c_movementTest_testMovementUp”);
EntityResponse initPlayer = TestUtils.getPlayer(initDungonRes).get();
// create the expected result
EntityResponse expectedPlayer = new EntityResponse(initPlayer.getId(), initPlayer.getType(),
new Position(1, 0), false);
// move player upward
DungeonResponse actualDungonRes = dmc.tick(Direction.UP);
EntityResponse actualPlayer = TestUtils.getPlayer(actualDungonRes).get();
// assert after movement
assertTrue(TestUtils.entityResponsesEqual(expectedPlayer, actualPlayer));
@Tag(“1-3”)
@DisplayName(“Test the player can move left”)
public void testMovementLeft() {
DungeonManiaController dmc = new DungeonManiaController();
DungeonResponse initDungonRes = dmc.newGame(
“d_movementTest_testMovementLeft”, “c_movementTest_testMovementLeft”);
EntityResponse initPlayer = TestUtils.getPlayer(initDungonRes).get();
// create the expected result
EntityResponse expectedPlayer = new EntityResponse(initPlayer.getId(), initPlayer.getType(),
new Position(0, 1), false);
// move player left
DungeonResponse actualDungonRes = dmc.tick(Direction.LEFT);
EntityResponse actualPlayer = TestUtils.getPlayer(actualDungonRes).get();
// assert after movement
assertTrue(TestUtils.entityResponsesEqual(expectedPlayer, actualPlayer));
@Tag(“1-4”)
@DisplayName(“Test the player can move right”)
public void testMovementRight() {
DungeonManiaController dmc = new DungeonManiaController();
DungeonResponse initDungonRes = dmc.newGame(
“d_movementTest_testMovementRight”, “c_movementTest_testMovementRight”);
EntityResponse initPlayer = TestUtils.getPlayer(initDungonRes).get();
// create the expected result
EntityResponse expectedPlayer = new EntityResponse(initPlayer.getId(),
initPlayer.getType(), new Position(2, 1), false);
// move player right
DungeonResponse actualDungonRes = dmc.tick(Direction.RIGHT);
EntityResponse actualPlayer = TestUtils.getPlayer(actualDungonRes).get();
// assert after movement
assertTrue(TestUtils.entityResponsesEqual(expectedPlayer, actualPlayer));
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com