123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 BananaTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class BananaTest
  12. {
  13. Product bananas;
  14. /**
  15. * Sets up the test fixture.
  16. *
  17. * Called before every test case method.
  18. */
  19. @Before
  20. public void setUp()
  21. {
  22. bananas = new Banana(.75, "492a", 10);
  23. }
  24. @Test
  25. public void testPrice(){
  26. double expected = .75;
  27. double actual = bananas.getPrice();
  28. assertEquals(expected, actual, 0);
  29. }
  30. @Test
  31. public void testSetPrice(){
  32. bananas.setPrice(.85);
  33. double expected = .85;
  34. double actual = bananas.getPrice();
  35. assertEquals(expected, actual, 0);;
  36. }
  37. @Test
  38. public void testId(){
  39. String expected = "492a";
  40. String actual = bananas.getId();
  41. assertEquals(expected, actual);
  42. }
  43. @Test
  44. public void testSetId(){
  45. bananas.setId("2817A");
  46. String expected = "2817A";
  47. String actual = bananas.getId();
  48. assertEquals(expected, actual);;
  49. }
  50. @Test
  51. public void testQuantity(){
  52. int expected = 10;
  53. int actual = bananas.getQuantity();
  54. assertEquals(expected, actual);;
  55. }
  56. @Test
  57. public void testSetQuantity(){
  58. bananas.setQuantity(50);
  59. int expected = 50;
  60. int actual = bananas.getQuantity();
  61. assertEquals(expected, actual);;
  62. }
  63. }