Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge austintests again
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class MinonTests extends TestCase{ | ||
|
||
private static int[][] nodes; | ||
private static final int NUM = 6; | ||
private MinionMock testMinion; | ||
|
||
protected void setUp()throws Exception{ | ||
nodes = new int[NUM][2];//setting up nodes for the map | ||
nodes[0][0] = 1; | ||
nodes[0][1] = 3; | ||
nodes[1][0] = 16; | ||
nodes[1][1] = 3; | ||
nodes[2][0] = 16; | ||
nodes[2][1] = 9; | ||
nodes[3][0] = 4; | ||
nodes[3][1] = 9; | ||
nodes[4][0] = 4; | ||
nodes[4][1] = 15; | ||
nodes[5][0] = 18; | ||
nodes[5][1] = 15; | ||
|
||
MockGui mg = new MockGui(640,640,32, NUM, nodes); | ||
StatGui sg= new StatGui(0,0); | ||
MapTowerDefense map = new MapTowerDefense(100, NUM, nodes, mg, sg); | ||
|
||
testMinion= new MinionMock(MinionTypes.BASIC, map); | ||
} | ||
|
||
public void testInitialLocation() throws Exception{ | ||
System.out.println("X= "+testMinion.getX() + " Y= "+testMinion.getY()); | ||
|
||
assertEquals(testMinion.getX(),32); | ||
assertEquals(testMinion.getY(),96); | ||
} | ||
|
||
public void testHealth() throws Exception{ | ||
assertEquals(testMinion.getHealth(),255); | ||
} | ||
|
||
public void testDamage() throws Exception{ | ||
testMinion.minionTakeHit(20); | ||
assertEquals(testMinion.getHealth(),235); | ||
} | ||
|
||
public void testMinionType() throws Exception{ | ||
System.out.println(testMinion.getName()); | ||
assertEquals(testMinion.getName(), "BASIC"); | ||
} | ||
|
||
public void testAlive() throws Exception{ | ||
assertTrue(testMinion.isAlive()); | ||
} | ||
|
||
public void testNotAlive() throws Exception{ | ||
testMinion.minionTakeHit(testMinion.getHealth()); | ||
assertFalse(testMinion.isAlive()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
import junit.framework.TestCase; | ||
|
||
|
||
public class StatGuiTests extends TestCase { | ||
|
||
private StatGui sg; | ||
|
||
protected void setUp() throws Exception{ | ||
sg= new StatGui(0,0); | ||
} | ||
|
||
public void testMoney() throws Exception{ | ||
assertEquals(sg.getMoney(), 1000); | ||
} | ||
|
||
public void testCanAfford() throws Exception{ | ||
assertTrue(sg.canAfford(sg.getMoney())); | ||
assertFalse(sg.canAfford(sg.getMoney()+10)); | ||
} | ||
|
||
public void testSpendMoney() throws Exception{ | ||
assertTrue(sg.spendMoney(sg.getMoney())); | ||
} | ||
|
||
public void testPayDay() throws Exception{ | ||
sg.spendMoney(sg.getMoney()); | ||
sg.payDay(100); | ||
|
||
assertEquals(sg.getMoney(), 100); | ||
} | ||
|
||
|
||
|
||
|
||
} |