/**
  * Validate the name and type of an individual resource.
  *
  * @param file MPP file
  * @param project project read from MPP file
  * @param id resource ID
  * @param expectedName expected name
  * @param expectedType expected type
  */
 private void testResource(
     File file, ProjectFile project, int id, String expectedName, ResourceType expectedType) {
   Resource resource = project.getResourceByID(Integer.valueOf(id));
   assertEquals(file.getName(), expectedName, resource.getName());
   assertEquals(file.getName(), expectedType, resource.getType());
 }
  /**
   * Common cost rate table tests.
   *
   * @param file project file
   */
  private void testCostRateTable(ProjectFile file) throws Exception {
    //
    // Resource with default tables
    //
    Resource resource = file.getResourceByID(Integer.valueOf(1));
    assertEquals("Resource One", resource.getName());

    // Table A
    CostRateTable table = resource.getCostRateTable(0);
    assertEquals(1, table.size());
    assertEquals(0, TimeUnit.HOURS, 0, TimeUnit.HOURS, 0, "31/12/2049 23:59", table, 0);

    // Table B
    table = resource.getCostRateTable(1);
    assertEquals(1, table.size());
    assertEquals(0, TimeUnit.HOURS, 0, TimeUnit.HOURS, 0, "31/12/2049 23:59", table, 0);

    // Table C
    table = resource.getCostRateTable(2);
    assertEquals(1, table.size());
    assertEquals(0, TimeUnit.HOURS, 0, TimeUnit.HOURS, 0, "31/12/2049 23:59", table, 0);

    // Table D
    table = resource.getCostRateTable(3);
    assertEquals(1, table.size());
    assertEquals(0, TimeUnit.HOURS, 0, TimeUnit.HOURS, 0, "31/12/2049 23:59", table, 0);

    // Table E
    table = resource.getCostRateTable(4);
    assertEquals(1, table.size());
    assertEquals(0, TimeUnit.HOURS, 0, TimeUnit.HOURS, 0, "31/12/2049 23:59", table, 0);

    //
    // Resource with default tables, but non-default values
    //
    resource = file.getResourceByID(Integer.valueOf(2));
    assertEquals("Resource Two", resource.getName());

    // Table A
    table = resource.getCostRateTable(0);
    assertEquals(1, table.size());
    assertEquals(5, TimeUnit.HOURS, 10, TimeUnit.HOURS, 15, "31/12/2049 23:59", table, 0);

    // Table B
    table = resource.getCostRateTable(1);
    assertEquals(1, table.size());
    assertEquals(20, TimeUnit.HOURS, 25, TimeUnit.HOURS, 30, "31/12/2049 23:59", table, 0);

    // Table C
    table = resource.getCostRateTable(2);
    assertEquals(1, table.size());
    assertEquals(35, TimeUnit.HOURS, 40, TimeUnit.HOURS, 45, "31/12/2049 23:59", table, 0);

    // Table D
    table = resource.getCostRateTable(3);
    assertEquals(1, table.size());
    assertEquals(50, TimeUnit.HOURS, 55, TimeUnit.HOURS, 60, "31/12/2049 23:59", table, 0);

    // Table E
    table = resource.getCostRateTable(4);
    assertEquals(1, table.size());
    assertEquals(65, TimeUnit.HOURS, 70, TimeUnit.HOURS, 75, "31/12/2049 23:59", table, 0);

    //
    // Resource with multiple values
    //
    resource = file.getResourceByID(Integer.valueOf(3));
    assertEquals("Resource Three", resource.getName());

    // Table A
    table = resource.getCostRateTable(0);
    assertEquals(2, table.size());
    assertEquals(5, TimeUnit.HOURS, 10, TimeUnit.HOURS, 15, "15/06/2009 08:00", table, 0);
    assertEquals(1200, TimeUnit.MINUTES, 25, TimeUnit.HOURS, 30, "31/12/2049 23:59", table, 1);

    // Table B
    table = resource.getCostRateTable(1);
    assertEquals(2, table.size());
    assertEquals(35, TimeUnit.HOURS, 40, TimeUnit.HOURS, 45, "16/06/2009 08:00", table, 0);
    assertEquals(6.25, TimeUnit.DAYS, 1.375, TimeUnit.WEEKS, 60, "31/12/2049 23:59", table, 1);

    // Table C
    table = resource.getCostRateTable(2);
    assertEquals(2, table.size());
    assertEquals(65, TimeUnit.HOURS, 70, TimeUnit.HOURS, 75, "17/06/2009 08:00", table, 0);
    assertEquals(0.5, TimeUnit.MONTHS, 0.040, TimeUnit.YEARS, 90, "31/12/2049 23:59", table, 1);

    // Table D
    table = resource.getCostRateTable(3);
    assertEquals(2, table.size());
    assertEquals(95, TimeUnit.HOURS, 100, TimeUnit.HOURS, 105, "18/06/2009 08:00", table, 0);
    assertEquals(110, TimeUnit.HOURS, 115, TimeUnit.HOURS, 120, "31/12/2049 23:59", table, 1);

    // Table E
    table = resource.getCostRateTable(4);
    assertEquals(2, table.size());
    assertEquals(125, TimeUnit.HOURS, 130, TimeUnit.HOURS, 135, "19/06/2009 08:00", table, 0);
    assertEquals(140, TimeUnit.HOURS, 145, TimeUnit.HOURS, 150, "31/12/2049 23:59", table, 1);

    //
    // Validate date-based row selection
    //
    CostRateTableEntry entry = table.getEntryByDate(m_df.parse("18/06/2009 07:00"));
    assertEquals(125, TimeUnit.HOURS, 130, TimeUnit.HOURS, 135, "19/06/2009 08:00", entry);
    entry = table.getEntryByDate(m_df.parse("19/06/2009 10:00"));
    assertEquals(140, TimeUnit.HOURS, 145, TimeUnit.HOURS, 150, "31/12/2049 23:59", table, 1);
  }