~ubuntu-branches/ubuntu/precise/triplea/precise

« back to all changes in this revision

Viewing changes to test/games/strategy/triplea/delegate/UnitsThatCantFightUtilTest.java

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2011-11-11 21:40:11 UTC
  • Revision ID: package-import@ubuntu.com-20111111214011-sehf2rwat36o2xqf
Tags: upstream-1.3.2.2
ImportĀ upstreamĀ versionĀ 1.3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
13
 */
 
14
 
 
15
package games.strategy.triplea.delegate;
 
16
 
 
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;
 
21
 
 
22
import java.util.Collection;
 
23
 
 
24
import junit.framework.TestCase;
 
25
 
 
26
public class UnitsThatCantFightUtilTest extends TestCase {
 
27
 
 
28
    
 
29
    
 
30
    
 
31
    public void testNoSuicideAttacksAA50AtStart()
 
32
    {
 
33
        //at the start of the game, there are no suicide attacks
 
34
        GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
 
35
        
 
36
        Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
 
37
        
 
38
        assertTrue(territories.isEmpty());
 
39
    }
 
40
    
 
41
    
 
42
    
 
43
    public void testSuicideAttackInAA50()
 
44
    {
 
45
        GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
 
46
        
 
47
        //add a german sub to sz 12       
 
48
        Territory sz12 = territory("12 Sea Zone", data);
 
49
        addTo(
 
50
         sz12,
 
51
         transports(data).create(1,germans(data))
 
52
         );
 
53
        
 
54
        Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
 
55
        
 
56
        assertTrue(territories.contains(sz12));
 
57
    }
 
58
    
 
59
    public void testSuicideAttackInAA50WithTransportedUnits()
 
60
    {
 
61
        GameData data = LoadGameUtil.loadGame("AA50", "ww2v3_1941.xml");
 
62
        
 
63
        //add a german sub to sz 12       
 
64
        Territory sz12 = territory("12 Sea Zone", data);
 
65
        addTo(
 
66
         sz12,
 
67
         transports(data).create(1,germans(data))
 
68
         );
 
69
        
 
70
        Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
 
71
        
 
72
        assertTrue(territories.contains(sz12));
 
73
    }
 
74
    
 
75
    
 
76
    public void testSuicideAttackInRevised()
 
77
    {
 
78
        GameData data = LoadGameUtil.loadGame("revised", "revised.xml");
 
79
             
 
80
        Territory sz15 = territory("15 Sea Zone", data);
 
81
        addTo(
 
82
         sz15,
 
83
         transports(data).create(1,germans(data))
 
84
         );
 
85
        
 
86
        Collection<Territory> territories = new UnitsThatCantFightUtil(data).getTerritoriesWhereUnitsCantFight(germans(data));
 
87
        
 
88
        assertTrue(territories.contains(sz15));
 
89
    }
 
90
    
 
91
}