diff --git a/MerchantRPGCSE2102/src/tests/TestMerchant.java b/MerchantRPGCSE2102/src/tests/TestMerchant.java new file mode 100644 index 0000000..91c84ea --- /dev/null +++ b/MerchantRPGCSE2102/src/tests/TestMerchant.java @@ -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()); + } +}