Exemple #1
0
  // test Track drop support
  public void testTrackDropSupport() {
    Location l = new Location("Location Test Drop id", "Location Test Name");
    Track t = new Track("Test id", "Test Name", "Test Type", l);
    Assert.assertEquals("Location Track Car id", "Test id", t.getId());
    Assert.assertEquals("Location Track Car Name", "Test Name", t.getName());
    Assert.assertEquals("Location Track Car Type", "Test Type", t.getTrackType());
    Assert.assertEquals("Location", l, t.getLocation());

    Assert.assertEquals("Location Track Drops Start", 0, t.getDropRS());
    Assert.assertEquals("Location Track Drops Start Reserved", 0, t.getReserved());

    Car c1 = new Car("TESTROAD", "TESTNUMBER1");
    c1.setLength("40");
    t.addDropRS(c1);
    Assert.assertEquals("Location Track Drops 1st", 1, t.getDropRS());
    Assert.assertEquals("Location Track Drops 1st Reserved", 40 + 4, t.getReserved());

    Car c2 = new Car("TESTROAD", "TESTNUMBER2");
    c2.setLength("50");
    t.addDropRS(c2);
    Assert.assertEquals("Location Track Drops 2nd", 2, t.getDropRS());
    Assert.assertEquals("Location Track Drops 2nd Reserved", 40 + 4 + 50 + 4, t.getReserved());

    t.deleteDropRS(c2);
    Assert.assertEquals("Location Track Drops 3rd", 1, t.getDropRS());
    Assert.assertEquals("Location Track Drops 3rd Reserved", 40 + 4, t.getReserved());

    t.deleteDropRS(c1);
    Assert.assertEquals("Location Track Drops 4th", 0, t.getDropRS());
    Assert.assertEquals("Location Track Drops 4th Reserved", 0, t.getReserved());
  }
Exemple #2
0
  // test Track attributes
  public void testTrackAttributes() {
    Location l = new Location("Location Test Attridutes id", "Location Test Name");
    Track t = new Track("Test id", "Test Name", "Test Type", l);
    Assert.assertEquals("Location Track id", "Test id", t.getId());
    Assert.assertEquals("Location Track Name", "Test Name", t.getName());
    Assert.assertEquals("Location Track Type", "Test Type", t.getTrackType());
    Assert.assertEquals("Location", l, t.getLocation());

    t.setName("New Test Name");
    Assert.assertEquals("Location Track set Name", "New Test Name", t.getName());

    t.setComment("New Test Comment");
    Assert.assertEquals("Location Track set Comment", "New Test Comment", t.getComment());

    t.setMoves(40);
    Assert.assertEquals("Location Track Moves", 40, t.getMoves());

    t.setLength(400);
    Assert.assertEquals("Location Track Length", 400, t.getLength());

    t.setReserved(200);
    Assert.assertEquals("Location Track Reserved", 200, t.getReserved());

    t.setUsedLength(100);
    Assert.assertEquals("Location Track Used Length", 100, t.getUsedLength());

    t.setTrainDirections(Track.NORTH);
    Assert.assertEquals("Location Track Direction North", Track.NORTH, t.getTrainDirections());

    t.setTrainDirections(Track.SOUTH);
    Assert.assertEquals("Location Track Direction South", Track.SOUTH, t.getTrainDirections());

    t.setTrainDirections(Track.EAST);
    Assert.assertEquals("Location Track Direction East", Track.EAST, t.getTrainDirections());

    t.setTrainDirections(Track.WEST);
    Assert.assertEquals("Location Track Direction West", Track.WEST, t.getTrainDirections());

    t.setTrainDirections(Track.NORTH + Track.SOUTH);
    Assert.assertEquals(
        "Location Track Direction North+South", Track.NORTH + Track.SOUTH, t.getTrainDirections());

    t.setTrainDirections(Track.EAST + Track.WEST);
    Assert.assertEquals(
        "Location Track Direction East+West", Track.EAST + Track.WEST, t.getTrainDirections());

    t.setTrainDirections(Track.NORTH + Track.SOUTH + Track.EAST + Track.WEST);
    Assert.assertEquals(
        "Location Track Direction North+South+East+West",
        Track.NORTH + Track.SOUTH + Track.EAST + Track.WEST,
        t.getTrainDirections());

    t.setRoadOption("New Test Road Option");
    Assert.assertEquals(
        "Location Track set Road Option", "New Test Road Option", t.getRoadOption());

    t.setDropOption("New Test Drop Option");
    Assert.assertEquals(
        "Location Track set Drop Option", "New Test Drop Option", t.getDropOption());

    t.setPickupOption("New Test Pickup Option");
    Assert.assertEquals(
        "Location Track set Pickup Option", "New Test Pickup Option", t.getPickupOption());
  }