ProductTest.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. *
  7. * Created by leon on 1/10/18.
  8. */
  9. public class ProductTest {
  10. @Test
  11. public void testEmptyConstructor() {
  12. Product product = new Product();
  13. }
  14. @Test
  15. public void testGetSetPrice() {
  16. Product product = new Product();
  17. double price = 88.99;
  18. product.setPrice(price);
  19. double actualPrice = product.getPrice();
  20. assertEquals(price, actualPrice, 0.01);
  21. }
  22. @Test
  23. public void testGetSetQuantity() {
  24. Product product = new Product ();
  25. int quantity = 12;
  26. product.setQuantity(quantity);
  27. int actualQuantity = product.getQuantity();
  28. assertEquals(quantity, actualQuantity);
  29. }
  30. @Test
  31. public void testGetId() {
  32. Product product = new Product();
  33. int productId = 123;
  34. product.setId(productId);
  35. int actualId = product.getId();
  36. assertEquals(productId, actualId);
  37. }
  38. @Test
  39. public void testConstructorWithIdPriceQuantity() {
  40. int productId = 19;
  41. double price = 12.99;
  42. int quantity = 7;
  43. Product newProduct = new Product(productId, price, quantity);
  44. }
  45. }