import junit.framework.TestCase;

/**
 * Test class Account.
 */
public class AccountTester extends TestCase {
  
  /**
   * Test whether the first constructor and toString interact properly.
   */
  public void testConstructor1AndToString() {
    Account account = new Account("Paul", 100.0, 1000.0);
    assertEquals("Paul: 100.0; 1000.0", account.toString());
  }
  
  /**
   * Test whether the second constructor and toString interact properly.
   */
  public void testConstructor2AndToString() {
    Account account = new Account("Paul", 10000.0);
    assertEquals("Paul: 10000.0; 0.0", account.toString());
  }
  
  /**
   * Test whether the third constructor and toString interact properly.
   */
  public void testConstructor3AndToString() {
    Account account = new Account("Paul, 2100.0, 1000.0");
    assertEquals("Paul: 2100.0; 1000.0", account.toString());
  }
  
  /**
   * Test whether the getter methods behave.
   */
  public void testGetters() {
    Account account = new Account("Paul", 2100.0, 1000.0);
    assertEquals("Paul", account.getOwner());
    assertEquals(2100.0, account.getBalance(), 0.0);
    assertEquals(1000.0, account.getMinBalance(), 0.0);
  }
  
  /**
   * Test whether depositing and withdrawing behave.
   */
  public void testDepositWithdraw() {
    Account account = new Account("Paul", 2100.0, 1000.0);
    account.deposit(250.0);
    assertEquals(2350.0, account.getBalance(), 0.0);
    account.withdraw(250.0);
    assertEquals(2100.0, account.getBalance(), 0.0);
  }
  
  /**
   * Test whether the minimum balance is working.
   */
  public void testMinBalance() {
    Account account = new Account("Paul", 2000.0, 1000.0);
    assertEquals(false, account.belowMinBalance());
    account.setMinBalance(3000.0);
    assertEquals(true, account.belowMinBalance());
    account.deposit(2000.0);
    assertEquals(false, account.belowMinBalance());

    // Borderline case.
    Account acc2 = new Account("Paul", 1000.0, 1000.0);
    assertEquals(false, acc2.belowMinBalance());
  }
  
}

