Beispiel #1
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());
  }
Beispiel #2
0
  // test Track car support
  public void testTrackCarSupport() {
    Location l = new Location("Location Test Car 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 Car Start Used Length", 0, t.getUsedLength());
    Assert.assertEquals("Location Track Car Start Number of Rolling Stock", 0, t.getNumberRS());
    Assert.assertEquals("Location Track Car Start Number of Cars", 0, t.getNumberCars());
    Assert.assertEquals("Location Track Car Start Number of Engines", 0, t.getNumberEngines());

    Car c1 = new Car("TESTROAD", "TESTNUMBER1");
    c1.setLength("40");
    t.addRS(c1);

    Assert.assertEquals("Location Track Car First Number of Rolling Stock", 1, t.getNumberRS());
    Assert.assertEquals("Location Track Car First Number of Cars", 1, t.getNumberCars());
    Assert.assertEquals("Location Track Car First Number of Engines", 0, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car First Used Length", 40 + 4, t.getUsedLength()); // Drawbar length is 4

    Car c2 = new Car("TESTROAD", "TESTNUMBER2");
    c2.setLength("33");
    t.addRS(c2);

    Assert.assertEquals("Location Track Car 2nd Number of Rolling Stock", 2, t.getNumberRS());
    Assert.assertEquals("Location Track Car 2nd Number of Cars", 2, t.getNumberCars());
    Assert.assertEquals("Location Track Car 2nd Number of Engines", 0, t.getNumberEngines());
    Assert.assertEquals("Location Track Car 2nd Used Length", 40 + 4 + 33 + 4, t.getUsedLength());

    jmri.jmrit.operations.rollingstock.engines.Engine e1 =
        new jmri.jmrit.operations.rollingstock.engines.Engine("TESTROAD", "TESTNUMBERE1");
    e1.setModel("E8"); // Default length == 70
    t.addRS(e1);

    Assert.assertEquals("Location Track Car 3rd Number of Rolling Stock", 3, t.getNumberRS());
    Assert.assertEquals("Location Track Car 3rd Number of Cars", 2, t.getNumberCars());
    Assert.assertEquals("Location Track Car 3rd Number of Engines", 1, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 3rd Used Length", 40 + 4 + 33 + 4 + 70 + 4, t.getUsedLength());

    Car c3 = new Car("TESTROAD", "TESTNUMBER3");
    c3.setLength("50");
    t.addRS(c3);

    Assert.assertEquals("Location Track Car 4th Number of Rolling Stock", 4, t.getNumberRS());
    Assert.assertEquals("Location Track Car 4th Number of Cars", 3, t.getNumberCars());
    Assert.assertEquals("Location Track Car 4th Number of Engines", 1, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 4th Used Length", 40 + 4 + 33 + 4 + 70 + 4 + 50 + 4, t.getUsedLength());

    Engine e2 = new Engine("TESTROAD", "TESTNUMBERE2");
    e2.setModel("E8"); // Default length == 70
    t.addRS(e2);

    Assert.assertEquals("Location Track Car 5th Number of Rolling Stock", 5, t.getNumberRS());
    Assert.assertEquals("Location Track Car 5th Number of Cars", 3, t.getNumberCars());
    Assert.assertEquals("Location Track Car 5th Number of Engines", 2, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 5th Used Length",
        40 + 4 + 33 + 4 + 70 + 4 + 50 + 4 + 70 + 4,
        t.getUsedLength()); // Drawbar length is 4

    t.deleteRS(c2);

    Assert.assertEquals("Location Track Car 6th Number of Rolling Stock", 4, t.getNumberRS());
    Assert.assertEquals("Location Track Car 6th Number of Cars", 2, t.getNumberCars());
    Assert.assertEquals("Location Track Car 6th Number of Engines", 2, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 6th Used Length", 40 + 4 + 70 + 4 + 50 + 4 + 70 + 4, t.getUsedLength());

    t.deleteRS(c1);

    Assert.assertEquals("Location Track Car 7th Number of Rolling Stock", 3, t.getNumberRS());
    Assert.assertEquals("Location Track Car 7th Number of Cars", 1, t.getNumberCars());
    Assert.assertEquals("Location Track Car 7th Number of Engines", 2, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 7th Used Length", 70 + 4 + 50 + 4 + 70 + 4, t.getUsedLength());

    t.deleteRS(e2);

    Assert.assertEquals("Location Track Car 8th Number of Rolling Stock", 2, t.getNumberRS());
    Assert.assertEquals("Location Track Car 8th Number of Cars", 1, t.getNumberCars());
    Assert.assertEquals("Location Track Car 8th Number of Engines", 1, t.getNumberEngines());
    Assert.assertEquals("Location Track Car 8th Used Length", 70 + 4 + 50 + 4, t.getUsedLength());

    t.deleteRS(e1);

    Assert.assertEquals("Location Track Car 9th Number of Rolling Stock", 1, t.getNumberRS());
    Assert.assertEquals("Location Track Car 9th Number of Cars", 1, t.getNumberCars());
    Assert.assertEquals("Location Track Car 9th Number of Engines", 0, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car 9th Used Length", 50 + 4, t.getUsedLength()); // Drawbar length is 4

    t.deleteRS(c3);

    Assert.assertEquals("Location Track Car Last Number of Rolling Stock", 0, t.getNumberRS());
    Assert.assertEquals("Location Track Car Last Number of Cars", 0, t.getNumberCars());
    Assert.assertEquals("Location Track Car Last Number of Engines", 0, t.getNumberEngines());
    Assert.assertEquals(
        "Location Track Car Last Used Length", 0, t.getUsedLength()); // Drawbar length is 4
  }