| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package com.zipcoder.payment;
-
- import org.junit.Assert;
- import org.junit.Test;
-
- public class PaymentPresenterTest {
-
- @Test
- public void testToStringNoPayment(){
- Payment[] payments = new Payment[0];
- PaymentPresenter presenter = new PaymentPresenter();
- String expected = "";
-
- String actual = presenter.toString(payments);
-
- Assert.assertEquals(expected,actual);
- }
-
- @Test
- public void testToStringMultiplePayments(){
- Payment[] payments = new Payment[2];
- Payment paypal = new PayPal("Tia Mowry", "tia@mowry.com");
- Payment check = new Check("Tia Mowry", "11432543","134344551");
-
- payments[0] = paypal;
- payments[1] = check;
-
- PaymentPresenter presenter = new PaymentPresenter();
- String expected = "Check Tia Mowry ****2543\nPaypal Tia Mowry tia@mowry.com\n";
-
- String actual = presenter.toString(payments);
- Assert.assertEquals(expected,actual);
- }
-
- @Test
- public void testToStringByPayerName(){
- Payment[] payments = new Payment[2];
- Payment paypal = new PayPal("Tamara Mowry", "tamara@mowry.com");
- Payment check = new Check("Tia Mowry", "11432543", "134344551");
-
- payments[0] = paypal;
- payments[1] = check;
-
- PaymentPresenter presenter = new PaymentPresenter();
- String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ****2543\n";
-
- String actual = presenter.toStringByPayerName(payments);
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void testToStringById(){
- Payment[] payments = new Payment[2];
- Payment paypal = new PayPal("Tamara Mowry", "tamara@mowry.com");
- Payment check = new Check("Tia Mowry", "11432543", "134344551");
- ((PayPal) paypal).setId(3L);
- ((Check) check).setId(1L);
-
- payments[0] = paypal;
- payments[1] = check;
-
- PaymentPresenter presenter = new PaymentPresenter();
- String expected = "Check Tia Mowry ****2543\nPaypal Tamara Mowry tamara@mowry.com\n";
-
- String actual = presenter.toStringById(payments);
- Assert.assertEquals(expected, actual);
- }
- }
|