InventoryTest.java 963B

1234567891011121314151617181920212223242526272829303132333435363738
  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. public class InventoryTest{
  7. @Test
  8. public void testAddInventory() {
  9. Inventory inventory = new Inventory();
  10. Product product = new Product();
  11. inventory.add(product);
  12. List<Product> products = inventory.getProducts();
  13. Product actualProduct = products.get(0);
  14. assertEquals(product, actualProduct);
  15. }
  16. @Test
  17. public void testGetTotalQuantity() {
  18. Inventory inventory = new Inventory();
  19. Product tea = new Product (1, 1.99, 10);
  20. Product coffee = new Product(9, 3.99, 5);
  21. inventory.add(tea);
  22. inventory.add(coffee);
  23. int actualQuantity = inventory.getTotalQuantity();
  24. int expectedQuantity = 15;
  25. assertEquals(expectedQuantity, actualQuantity);
  26. }
  27. }