예제 #1
0
  @Test
  public final void testUse_hitWall() {
    // setup a long strait of squares
    SquareContainer first = square;
    SquareContainer goal = null;
    for (int i = 0; i < 10; i++) {
      Map<Direction, SquareContainer> neighbours = new HashMap<Direction, SquareContainer>();
      neighbours.put(Direction.WEST, square);

      if (i == 7) {
        goal = square;
        square = new SquareContainer(neighbours, new WallPart());
        continue;
      }
      square = new SquareContainer(neighbours, new NormalSquare());
    }

    // USE THE ID TO THE EAST
    DummyIDArgumentsHandler idHandler = new DummyIDArgumentsHandler();
    idHandler.setChoice(2);
    UseArguments<?> arguments = identityDisk.getUseArguments();
    if (arguments != null) idHandler.handleArguments(arguments);
    identityDisk.use(first, arguments);

    assertEquals(identityDisk, goal.getAllItems().get(0));
    assertTrue(square.getAllItems().isEmpty());
  }
예제 #2
0
  @Test
  public final void testUse_ItemCannotMove() {
    // USE THE ID TO THE EAST
    DummyIDArgumentsHandler idHandler = new DummyIDArgumentsHandler();
    idHandler.setChoice(2);
    UseArguments<?> arguments = identityDisk.getUseArguments();
    if (arguments != null) idHandler.handleArguments(arguments);
    identityDisk.use(square, arguments);

    assertEquals(identityDisk, square.getAllItems().get(0));
  }
예제 #3
0
  @Test
  public final void testUse() {

    // setup a long strait of squares
    SquareContainer container =
        new SquareContainer(Collections.<Direction, SquareContainer>emptyMap(), new NormalSquare());
    SquareContainer first = container;
    for (int i = 0; i < 10; i++) {
      Map<Direction, SquareContainer> neighbours = new HashMap<Direction, SquareContainer>();
      neighbours.put(Direction.WEST, container);
      container = new SquareContainer(neighbours, new NormalSquare());
    }

    // USE THE ID TO THE EAST
    DummyIDArgumentsHandler idHandler = new DummyIDArgumentsHandler();
    idHandler.setChoice(2);
    UseArguments<?> arguments = identityDisk.getUseArguments();
    if (arguments != null) idHandler.handleArguments(arguments);
    identityDisk.use(first, arguments);

    assertEquals(identityDisk, container.getAllItems().get(0));
  }