12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
-
-
- import org.junit.Assert;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class InventoryTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class InventoryTest
- {
- @Test
- public void addItemTest1() {
- String expected = "dragon";
-
- Inventory danysStuff = new Inventory();
- danysStuff.addItem(new Product(25.00f, 3, "dragon"));
-
- Product dragon = danysStuff.getItem("dragon");
- String actual = dragon.getID();
-
- Assert.assertEquals(actual, expected);
- }
- @Test
- public void addItemTest2() {
- String expected = "dragon";
-
- Inventory danysStuff = new Inventory();
- danysStuff.addItem(25.00f, 3, "dragon");
-
- Product dragon = danysStuff.getItem("dragon");
- String actual = dragon.getID();
-
- Assert.assertEquals(actual, expected);
- }
- @Test
- public void addUnitsTest() {
- int expected = 6;
-
- Inventory danysStuff = new Inventory();
- danysStuff.addItem(new Product(25.00f, 3, "dragon"));
- danysStuff.addUnits("dragon", 3);
-
- int actual = danysStuff.getOnHandQuantity("dragon");
-
- Assert.assertEquals(actual, expected);
- }
- @Test
- public void removeUnitsTest() {
- int expected = 2;
-
- Inventory danysStuff = new Inventory();
- danysStuff.addItem(25.00f, 3, "dragon");
- danysStuff.removeUnits("dragon", 1);
-
- int actual = danysStuff.getOnHandQuantity("dragon");
-
- Assert.assertEquals(actual, expected);
- }
- @Test
- public void updatePriceTest() {
- float expected = 516.99f;
-
- Inventory danysStuff = new Inventory();
- danysStuff.addItem(25.00f, 3, "dragon");
- danysStuff.updatePrice("dragon", 516.99f);
- float actual = danysStuff.getPrice("dragon");
-
- Assert.assertEquals(actual, expected, 0.001f);
- }
- @Test
- public void inventoryValueTest() {
- double expected = 57.44;
-
- Inventory starkStuff = new Inventory();
- starkStuff.addItem(3.00f, 9, "direwolf collar");
- starkStuff.addItem(2.50f, 5, "direworlf treat");
- starkStuff.addItem(2.99f, 6, "winterfell snowglobe");
- double actual = starkStuff.getInventoryValue();
-
- Assert.assertEquals(actual, expected, 0.001f);
- }
- }
|