import junit.framework.TestCase;

/**
 * A JUnit test case class testing AVEquipment.
 */
public class AVEquipmentTester extends TestCase {
  
  /**
   * Tests whether consecutive serial numbers are assigned
   * to successive instances of AVEquipment created by Constructor1.
   */
  public void testConstructor1AndSerial() {
    AVEquipment aVE1= new AVEquipment(); // use the constructor without paramters
    AVEquipment aVE2= new AVEquipment(); // constructor without paramters
    assertEquals(aVE1.getAVEquipmentID() +1, aVE2.getAVEquipmentID());
  }
  /**
   * Tests whether consecutive serial numbers are assigned
   * to successive instances of AVEquipment created by Constructor2.
   */
  public void testConstructor2AndSerial() {
    AVEquipment aVE1= new AVEquipment("projector"); // use the constructor with paramters
    AVEquipment aVE2= new AVEquipment("othertype"); // constructor with paramters
    assertEquals(aVE1.getAVEquipmentID() +1, aVE2.getAVEquipmentID());
  }

  /**
   * Tests whether consecutive serial numbers are assigned
   * to successive instances of AVEquipment; one created by 
   * Constructor1, the other by Constructor2.
   */
  public void testConstructor1And2AndSerial() {
    AVEquipment aVE1= new AVEquipment(); // use the constructor without paramters
    AVEquipment aVE2= new AVEquipment("othertype"); // constructor with paramters
    assertEquals(aVE1.getAVEquipmentID() +1, aVE2.getAVEquipmentID());
  }

  /**
   * Tests whether consecutive serial numbers are assigned
   * to successive instances of AVEquipment; the first created by 
   * Constructor2, the second by Constructor1.
   */
  public void testConstructor2And1AndSerial() {
    AVEquipment aVE1= new AVEquipment("sometype"); // constructor with paramters
    AVEquipment aVE2= new AVEquipment(); // use the constructor without paramters
    assertEquals(aVE1.getAVEquipmentID() +1, aVE2.getAVEquipmentID());
  }
  /**
   * Tests whether the counter for the total number of instances
   * created is properly incremented by Constructor1. 
   */
  public void testConstructor1AndTotalAVs() {
    int numPieces = AVEquipment.getTotalAVs();
    AVEquipment aVE1= new AVEquipment(); // constructor without paramters
    assertEquals(numPieces+1, AVEquipment.getTotalAVs());
  }
  
  /**
   * Tests whether the counter for the total number of instances
   * created is properly incremented by Constructor2. 
   */
  public void testConstructor2AndTotalAVs() {
    int numPieces = AVEquipment.getTotalAVs();
    AVEquipment aVE1= new AVEquipment("sometype"); // constructor with paramters
    assertEquals(numPieces+1, AVEquipment.getTotalAVs());
  }
  
  /**
   * Tests whether an instance of AVEquipment is equal to itself
   */
  public void testEquals() {
    AVEquipment AVE = new AVEquipment();
    assertTrue(AVE.equals(AVE));
  }
  
  /**
   * Tests whether getType() returns the equipment type set 
   * by Constructor2.
   */
  public void testGetTypeAndConstr2() {
    String type = "This type";
    AVEquipment AVE = new AVEquipment(type);
    assertEquals(type, AVE.getType());
  }
  /**
   * Tests whether setType() overwrites the equipment type.
   */
  public void testSetType() {
    String type1 = "Another type";
    String type2 = "";
    AVEquipment AVE = new AVEquipment(type1);
    AVE.setType(type2);
    assertEquals(type2, AVE.getType());
  }
}
