PayPalTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.zipcoder.payment;
  2. import org.junit.Test;
  3. import static junit.framework.TestCase.assertEquals;
  4. import static junit.framework.TestCase.assertTrue;
  5. public class PayPalTest {
  6. @Test
  7. public void testGetter(){
  8. long expected = 1;
  9. PayPal payPal = new PayPal(3, "kevin", "K@yahoo.com");
  10. payPal.setId(1);
  11. long actual = payPal.getId();
  12. assertEquals(expected, actual);
  13. }
  14. @Test
  15. public void testPayerName(){
  16. String expected = "Marie";
  17. PayPal payPal = new PayPal(2, "Marie", "m@yahoo.com");
  18. payPal.setPayerName("Marie");
  19. String actual = payPal.getPayerName();
  20. assertEquals(expected, actual);
  21. }
  22. @Test
  23. public void testEmail(){
  24. String expected = "abs@yahoo.com";
  25. PayPal payPal = new PayPal(1, "john", "j@yahoo.com");
  26. payPal.setEmail("abs@yahoo.com");
  27. String actual = payPal.getEmail();
  28. assertEquals(expected, actual);
  29. }
  30. @Test
  31. public void testCompareToGreaterThan(){
  32. int expected = 0;
  33. Payment payPal = new PayPal(4, "Tia Mowry", "tia@mowry.com");
  34. Payment check = new Check(6, "Tia Mowry", "2323", "4556");
  35. int actual = payPal.compareTo(check);
  36. assertTrue(actual > expected);
  37. }
  38. @Test
  39. public void testCompareToEqual(){
  40. int expected = 0;
  41. Payment payPal = new PayPal(7, "Matt", "m@yahoo.com");
  42. Payment payPal2 = new PayPal(7, "Matt", "m@yahoo.com");
  43. int actual = payPal.compareTo(payPal2);
  44. assertTrue(actual == expected);
  45. }
  46. @Test
  47. public void testCompareToLessThan(){
  48. int expected = 0;
  49. Payment payPal = new PayPal(3, "Kay", "k@yahoo.com");
  50. Payment check = new Check(2, "Leo", "55666", "5678");
  51. int actual = payPal.compareTo(check);
  52. }
  53. }