InventoryTest.java 1007B

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