/**
   * 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));
  }
  public void testBellNetProduction() {
    Game game = getStandardGame();

    game.setMap(getTestMap());

    Colony colony = getStandardColony(7);

    int initialBellCount = colony.getGoodsCount(bellsType);
    int expectedBellCount = 0;
    int bellsProdPerTurn = colony.getTotalProductionOf(bellsType);
    int expectedBellProd = 1;
    int bellsUpkeep = colony.getConsumptionOf(bellsType);
    int expectedBellUpkeep = colony.getUnitCount() - 2;
    int bellsNetProdPerTurn = colony.getNetProductionOf(bellsType);
    int expectedBellNetProd = expectedBellProd - expectedBellUpkeep;

    assertEquals("Wrong bell count", expectedBellCount, initialBellCount);
    assertEquals("Wrong bell production", expectedBellProd, bellsProdPerTurn);
    assertEquals("Wrong bell upkeep", expectedBellUpkeep, bellsUpkeep);
    assertEquals("Wrong bell net production", expectedBellNetProd, bellsNetProdPerTurn);
  }
  public void testProduction() {
    Game game = getGame();
    game.setMap(getTestMap());

    Colony colony = getStandardColony(3);
    ColonyTile tile = colony.getColonyTile(colony.getTile());

    assertEquals(0, colony.getGoodsCount(foodType));

    assertEquals(grainType, tile.getProduction().get(0).getType());
    assertEquals(5, tile.getProduction().get(0).getAmount());
    assertEquals(cottonType, tile.getProduction().get(1).getType());
    assertEquals(2, tile.getProduction().get(1).getAmount());

    for (Unit unit : colony.getUnitList()) {
      ProductionInfo unitInfo = colony.getProductionInfo(unit);
      assertNotNull(unitInfo);
      assertEquals(2, unitInfo.getConsumption().size());
      assertEquals(2, unitInfo.getMaximumConsumption().size());
      ProductionInfo tileInfo = colony.getProductionInfo(unit.getLocation());
      assertEquals(1, tileInfo.getProduction().size());
      assertEquals(grainType, tileInfo.getProduction().get(0).getType());
      assertEquals(5, tileInfo.getProduction().get(0).getAmount());
    }

    /*
    TypeCountMap<GoodsType> grossProduction = new TypeCountMap<GoodsType>();
    TypeCountMap<GoodsType> netProduction = new TypeCountMap<GoodsType>();
    for (ProductionInfo productionInfo : info.values()) {
        for (AbstractGoods goods : productionInfo.getProduction()) {
            grossProduction.incrementCount(goods.getType(), goods.getAmount());
            netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount());
        }
        for (AbstractGoods goods : productionInfo.getStorage()) {
            grossProduction.incrementCount(goods.getType(), goods.getAmount());
            netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount());
        }
        for (AbstractGoods goods : productionInfo.getConsumption()) {
            netProduction.incrementCount(goods.getType().getStoredAs(), -goods.getAmount());
        }
    }

    assertEquals(2, grossProduction.getCount(cottonType));
    assertEquals(2, colony.getNetProductionOf(cottonType));

    assertEquals(20, grossProduction.getCount(grainType));
    assertEquals(0, colony.getNetProductionOf(grainType));

    assertEquals(3, grossProduction.getCount(bellsType));
    assertEquals(0, colony.getNetProductionOf(bellsType));

    assertEquals(1, grossProduction.getCount(crossesType));
    assertEquals(1, colony.getNetProductionOf(crossesType));

    // this is storage only
    assertEquals(7, grossProduction.getCount(foodType));
    // this includes implicit type change and consumption
    assertEquals(14, colony.getNetProductionOf(foodType));

    colony.addGoods(horsesType, 50);
    colony.getUnitList().get(0).setWorkType(cottonType);
    Building weaverHouse = colony.getBuilding(spec().getBuildingType("model.building.weaverHouse"));
    colony.getUnitList().get(1).setLocation(weaverHouse);

    info = colony.getProductionAndConsumption();

    assertEquals(grainType, tile.getProduction().get(0).getType());
    assertEquals(5, tile.getProduction().get(0).getAmount());
    assertEquals(cottonType, tile.getProduction().get(1).getType());
    assertEquals(2, tile.getProduction().get(1).getAmount());

    grossProduction = new TypeCountMap<GoodsType>();
    netProduction = new TypeCountMap<GoodsType>();
    for (ProductionInfo productionInfo : info.values()) {
        for (AbstractGoods goods : productionInfo.getProduction()) {
            grossProduction.incrementCount(goods.getType(), goods.getAmount());
            netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount());
        }
        for (AbstractGoods goods : productionInfo.getStorage()) {
            grossProduction.incrementCount(goods.getType(), goods.getAmount());
            netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount());
        }
        for (AbstractGoods goods : productionInfo.getConsumption()) {
            netProduction.incrementCount(goods.getType().getStoredAs(), -goods.getAmount());
        }
    }

    assertEquals(4, grossProduction.getCount(cottonType));
    assertEquals(1, colony.getNetProductionOf(cottonType));

    assertEquals(3, grossProduction.getCount(clothType));
    assertEquals(3, colony.getNetProductionOf(clothType));

    assertEquals(10, grossProduction.getCount(grainType));
    assertEquals(0, colony.getNetProductionOf(grainType));

    assertEquals(2, grossProduction.getCount(horsesType));
    assertEquals(2, colony.getNetProductionOf(horsesType));

    assertEquals(3, grossProduction.getCount(bellsType));
    assertEquals(0, colony.getNetProductionOf(bellsType));

    assertEquals(1, grossProduction.getCount(crossesType));
    assertEquals(1, colony.getNetProductionOf(crossesType));

    // this is storage only
    assertEquals(2, grossProduction.getCount(foodType));
    // this includes implicit type change and consumption
    assertEquals(2, colony.getNetProductionOf(foodType));

    */
  }