コード例 #1
0
  /**
   * Tests that there is no over production of horses, to avoid them being thrown out. A test of the
   * proper production of horses is in <code>BuildingTest</code>
   */
  public void testNoHorsesOverProduction() {
    Game game = getGame();
    game.setMap(getTestMap());

    Colony colony = getStandardColony(1);

    Building pasture = colony.getBuilding(countryType);
    assertEquals(horsesType, pasture.getGoodsOutputType());
    assertEquals(
        "Wrong warehouse capacity in colony",
        GoodsContainer.CARGO_SIZE,
        colony.getWarehouseCapacity());

    // Still room for more
    colony.addGoods(horsesType, 99);
    assertTrue(colony.getNetProductionOf(foodType) > 0);

    assertEquals("Wrong horse production", 1, pasture.getTotalProductionOf(horsesType));
    assertEquals("Wrong maximum horse production", 1, pasture.getMaximumProductionOf(horsesType));
    assertEquals("Wrong net horse production", 1, colony.getNetProductionOf(horsesType));

    // No more room available
    colony.addGoods(horsesType, 1);
    assertEquals(
        "Wrong number of horses in colony",
        colony.getWarehouseCapacity(),
        colony.getGoodsCount(horsesType));
    assertEquals("Wrong horse production", 0, pasture.getTotalProductionOf(horsesType));
    assertEquals("Wrong maximum horse production", 0, pasture.getMaximumProductionOf(horsesType));
    assertEquals("Wrong net horse production", 0, colony.getNetProductionOf(horsesType));
  }