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
Tests for MockGui
- Loading branch information
Showing
2 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,70 @@ | ||
package tests; | ||
|
||
import static org.junit.Assert.*; | ||
import MockGui; | ||
|
||
import java.awt.Color; | ||
|
||
import org.junit.Test; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class MockGuiTests extends TestCase{ | ||
|
||
MockGui mg; | ||
public void setUp(){ | ||
int[][] nodes; | ||
int NUM = 6; | ||
nodes = new int[NUM][2]; | ||
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; | ||
mg = new MockGui(640, 640, 32, NUM, nodes); | ||
} | ||
|
||
@Test | ||
public void testHashX() { | ||
int ans[] = mg.hash(20, 10); | ||
|
||
assertEquals(ans[0],640); | ||
//assertEquals(ans[1],320); | ||
} | ||
|
||
@Test | ||
public void testHashY(){ | ||
int ans[] = mg.hash(20, 10); | ||
assertEquals(ans[1],320); | ||
} | ||
|
||
@Test | ||
public void testUnhashX() { | ||
int ans[] = mg.unhash(96, 10); | ||
assertEquals(ans[0],3); | ||
} | ||
|
||
@Test | ||
public void testUnhashY() { | ||
int ans[] = mg.unhash(96, 128); | ||
assertEquals(ans[1],4); | ||
} | ||
|
||
public void testColor(){ | ||
mg.setBackground(Color.BLACK); | ||
Color aColor = mg.getBackground(); | ||
assertEquals(aColor, Color.BLACK); | ||
} | ||
|
||
public void testTowerSetup(){ | ||
|
||
} | ||
|
||
} |