import junit.framework.*;
import java.io.ByteArrayInputStream;

/********************************************
 * CSCard_Test tests the CSCard class
 * @author <<<who are you?>>>
 * @version 3/3/2014
 ********************************************/
public class CSCard_Test extends TestCase 
{
   /********************************************
    * main invokes the JUnit test runner
    *
    * @param args unused in this application
    *******************************************/
   public static void main (String args[])
   {
      org.junit.runner.JUnitCore.main("CSCard_Test");
   }
   
   /*******************************************
    * testCalculateInterest will thoroughly 
    * test the calculateInterest method
    ******************************************/
   public static void testCalculateInterest() 
   {
      double expectedInterest;
      double actualInterest;
      
      CSCard card;
      card = new CSCard();
      
      expectedInterest = 0.0;
      actualInterest = card.calculateInterest(0, 125.25);
      assertEquals("Error in calculateInterest: ", expectedInterest, actualInterest); 
   }
   
   /*******************************************
    * testCalculateMinPayment will thoroughly 
    * test the calculateInterest method
    ******************************************/
   public static void testCalculateMinPayment() 
   {
      double expectedPayment;
      double actualPayment;
      
      CSCard card;
      card = new CSCard();
      
      expectedPayment = 100.00;
      actualPayment = card.calculateMinPayment(500.00);
      assertEquals("Error in calculateMinPayment: ", 
         expectedPayment, actualPayment); 
   }

   /** test to execute createStatement DO NOT CHANGE */
   public static void testCreateStatement()
   {
      CSCard credit;
      String input;
     
      credit = new CSCard();
     
      input = "75.00\n50.00\n";
     
     // redirect standard in/out
      System.setIn(new ByteArrayInputStream(input.getBytes()));
      
      
      credit.createStatement();
      
      input = "a\na\n";
     
     // redirect standard in/out
      System.setIn(new ByteArrayInputStream(input.getBytes()));

      credit.createStatement();
   }
   /** test to execute the Driver DO NOT CHANGE */
   public static void testDriver()
   {
      String input; 
      CSCardDriver driver;    
    
      input = "75.00\n50.00\n";
     
     // redirect standard in/out
      System.setIn(new ByteArrayInputStream(input.getBytes()));
      
      driver = new CSCardDriver();
      driver.main(null);
   }
}