Пример #1
0
  @Test
  public void runTest() {
    Field field = new Field();
    ArrayList<String> args = new ArrayList<String>();

    Teleport teleportCommand = new Teleport();
    Point playerPos;

    Init initCommand = new Init();
    ArrayList<String> argsInit = new ArrayList<String>();
    argsInit.add("10");
    argsInit.add("10");
    argsInit.add("4");
    argsInit.add("4");
    initCommand.run(field, argsInit);

    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 4);
    assertEquals(playerPos.y, 4);

    args.add("0");
    args.add("0");
    teleportCommand.run(field, args);
    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 0);
    assertEquals(playerPos.y, 0);

    args.clear();
    args.add("4");
    args.add("5");
    teleportCommand.run(field, args);
    playerPos = field.getPlayerPosition();
    assertEquals(playerPos.x, 4);
    assertEquals(playerPos.y, 5);
  }
Пример #2
0
  @Test(expected = IllegalArgumentException.class)
  public void runTestIllegalArgumentException() throws IllegalArgumentException {
    Field field = new Field();
    ArrayList<String> args = new ArrayList<String>();

    Teleport teleportCommand = new Teleport();

    Init initCommand = new Init();
    ArrayList<String> argsInit = new ArrayList<String>();
    argsInit.add("10");
    argsInit.add("10");
    argsInit.add("4");
    argsInit.add("4");
    initCommand.run(field, argsInit);

    teleportCommand.run(field, args);
  }