예제 #1
0
 @Test
 public void testPower() {
   TChronoTimer timer = new TChronoTimer();
   assertTrue(!timer.isOn());
   assertTrue(timer.togglePower());
   assertTrue(timer.togglePower());
   assertTrue(timer.powerOn());
   assertTrue(timer.powerOff());
 }
예제 #2
0
  public void testRunner() {
    TChronoTimer timer = new TChronoTimer();
    timer.setPower(true);
    assertTrue(timer.isOn());
    timer.getTimeManager().setTime("00:00:00");
    timer.toggleChannel(1);
    timer.toggleChannel(2);
    LinkedList<TRacer> racers = new LinkedList<TRacer>();

    for (int i = 0; i < 10; i++) {
      racers.add(new TRacer(i));

      assertEquals(racers.get(i).getID(), i);
      assertEquals(racers.get(i).getRecords().get(timer.getLatestRun().getID()).getStartTime(), -1);
      assertEquals(
          racers.get(i).getRecords().get(timer.getLatestRun().getID()).getFinishTime(), -1);
      assertFalse(racers.get(i).getRecords().get(timer.getLatestRun().getID()).isFinished());

      timer.getLatestRun().addRacer(i);
    }

    List<Channel> channels = timer.getChannels();
    for (int i = 0; i < 10; i++) {
      long st, fin;
      timer.trigger(channels.get(0));
      st =
          timer
              .getLatestRun()
              .getRacers()
              .get(i)
              .getRecords()
              .get(timer.getLatestRun().getID())
              .getStartTime();

      assertFalse(st == -1);
      assertFalse(
          timer
              .getLatestRun()
              .getRacers()
              .get(i)
              .getRecords()
              .get(timer.getLatestRun().getID())
              .didNotFinish());

      timer.trigger(channels.get(1));
      fin =
          timer
              .getLatestRun()
              .getRacers()
              .get(i)
              .getRecords()
              .get(timer.getLatestRun().getID())
              .getFinishTime();

      assertFalse(fin == -1);
      assertTrue(fin - st > 0);
      assertFalse(
          timer
              .getLatestRun()
              .getRacers()
              .get(i)
              .getRecords()
              .get(timer.getLatestRun().getID())
              .didNotFinish());
    }
  }