-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed TestMerchant to better fit in with coding conventions
- Loading branch information
Gavin Li
committed
Feb 3, 2015
1 parent
1b37cbd
commit cd697e5
Showing
1 changed file
with
56 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,56 @@ | ||
package tests; | ||
|
||
import game.Merchant; | ||
import junit.framework.TestCase; | ||
|
||
|
||
public class TestMerchant extends TestCase | ||
{ | ||
private Merchant m; | ||
|
||
public void setup() | ||
{ | ||
m = new Merchant("Test", 100, 2); | ||
} | ||
|
||
//testing cash system | ||
public void testCashSystem() throws Exception | ||
{ | ||
setup(); | ||
assertEquals(-1, m.decrementCash(101)); | ||
m.incrementCash(100); | ||
m.refreshCash(); | ||
assertEquals(200, m.getCurrentCash()); | ||
m.decrementCash(120); | ||
assertEquals(80, m.getCurrentCash()); | ||
} | ||
|
||
//testing randomizer | ||
public void testRandomizer() throws Exception | ||
{ | ||
setup(); | ||
boolean testCheck = false; | ||
m.setDailyRandomPrice(10, 50); | ||
|
||
if(10 <= m.getRandomPrice() && 50 >= m.getRandomPrice()) | ||
{ | ||
testCheck = true; | ||
} | ||
|
||
assertEquals(true, testCheck); | ||
} | ||
|
||
//testing inventory | ||
public void testInventory() throws Exception | ||
{ | ||
setup(); | ||
assertEquals(2, m.getInventory().length); | ||
} | ||
|
||
//testing name | ||
public void testName() throws Exception | ||
{ | ||
setup(); | ||
assertEquals("Test", m.getName()); | ||
} | ||
} |