123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
-
-
- import static 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 testAdd(){
- //Given
- Inventory inventory = new Inventory();
- Product product = new Product(1, "Herbal Tea", 1.60, 1);
-
- //When
- inventory.add(product);
-
- //Then
- int actualSize = inventory.size();
- int expectedSize = 1;
-
- assertEquals(expectedSize, actualSize);
- }
-
- @Test
- public void testGetProductByID() {
- Inventory inventory = new Inventory();
- int productID = 85;
- Product expectedProduct = new Product(productID, "Coffee", 4.60, 1);
-
- inventory.add(expectedProduct);
-
- Product actualProduct = inventory.getProductByID(productID);
-
- assertEquals(expectedProduct, actualProduct);
- }
-
- @Test
- public void testSumQuantity(){
- Inventory myInventory = new Inventory();
-
- Product product = new Product(86, "Herbal Tea", 1.6, 2);
- Product product2 = new Product(87, "Black Tea", 2.0, 2);
- Product product3 = new Product(88, "Green Tea", 3.5, 6);
-
- myInventory.add(product);
- myInventory.add(product2);
- myInventory.add(product3);
-
- int expectedQuantity = 10;
- int actualQuantity = myInventory.getSumQuantity();
-
- assertEquals(expectedQuantity, actualQuantity);
-
-
- }
- }
|