InventoryTest.java 777B

123456789101112131415161718192021222324252627282930313233
  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. public class InventoryTest
  12. {
  13. @Test
  14. public void sumInventoryTest()
  15. {
  16. //Given
  17. Inventory inventory = new Inventory();
  18. Product apple = new Product("apple",1.99,"12345",500);
  19. Product orange = new Product("orange",1.50,"12346",400);
  20. inventory.addProductToInventory(apple);
  21. inventory.addProductToInventory(orange);
  22. //Actual
  23. double actual = inventory.sumInventoryValue();
  24. //Expected
  25. double expected = 1595.0;
  26. //Test
  27. assertEquals(expected,actual,.01);
  28. }
  29. }