2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
package games.strategy.triplea.delegate;
17
import static games.strategy.triplea.delegate.GameDataTestUtil.*;
18
import games.strategy.engine.data.GameData;
19
import games.strategy.engine.data.Territory;
20
import games.strategy.triplea.xml.LoadGameUtil;
22
import java.util.Collection;
24
import junit.framework.TestCase;
26
public class UnitsThatCantFightUtilTest extends TestCase {
31
public void testNoSuicideAttacksAA50AtStart()
33
//at the start of the game, there are no suicide attacks
34
GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
36
Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
38
assertTrue(territories.isEmpty());
43
public void testSuicideAttackInAA50()
45
GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
47
//add a german sub to sz 12
48
Territory sz12 = territory("12 Sea Zone", data);
51
transports(data).create(1,germans(data))
54
Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
56
assertTrue(territories.contains(sz12));
59
public void testSuicideAttackInAA50WithTransportedUnits()
61
GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
63
//add a german sub to sz 12
64
Territory sz12 = territory("12 Sea Zone", data);
67
transports(data).create(1,germans(data))
70
Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
72
assertTrue(territories.contains(sz12));
76
public void testSuicideAttackInRevised()
78
GameData data = LoadGameUtil.loadGame("revised", "revised.xml");
80
Territory sz15 = territory("15 Sea Zone", data);
83
transports(data).create(1,germans(data))
86
Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
88
assertTrue(territories.contains(sz15));