InventoryTest.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class InventoryTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. import java.util.List;
  12. public class InventoryTest
  13. {
  14. @Test
  15. public void testAddInventory(){
  16. Inventory inventory = new Inventory();
  17. Product product = new Product();
  18. inventory.add(product);
  19. List<Product> products = inventory.getProducts();
  20. Product actualProduct = products.get(0);
  21. assertEquals(product, actualProduct);
  22. }
  23. @Test
  24. public void testGetTotalQuantity(){
  25. Inventory inventory = new Inventory();
  26. Product tea = new Product(1, 1.99, 10);
  27. Product coffee = new Product(9, 3.99, 5);
  28. inventory.add(tea);
  29. inventory.add(coffee);
  30. int actualQuantity = inventory.getTotalQuantity();
  31. int expectedQuantity = 15;
  32. assertEquals(expectedQuantity, actualQuantity);
  33. }
  34. }