Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
StatGui and MinionMock tests
  • Loading branch information
akf12001 committed Apr 30, 2015
1 parent 1edbead commit c341415
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/MinionMock.java
Expand Up @@ -116,6 +116,8 @@ public class MinionMock {

public void minionTakeHit(int damage) {
health-=damage;
if(health <= 0)
alive= false;
}

public void minionTakeDamage() {
Expand Down
62 changes: 60 additions & 2 deletions src/tests/MinonTests.java
@@ -1,5 +1,63 @@
package tests;

public class MinonTests {
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());
}


}
37 changes: 37 additions & 0 deletions src/tests/StatGuiTests.java
@@ -0,0 +1,37 @@
package tests;
import StatGui;
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);
}




}

0 comments on commit c341415

Please sign in to comment.