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 typename support
  public void testTrackTypeNameSupport() {
    Location l = new Location("Location Test Name 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());

    /* Test Type Name */
    Assert.assertEquals(
        "Location Track Accepts Type Name undefined", false, t.acceptsTypeName("TestTypeName"));

    t.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined", false, t.acceptsTypeName("TestTypeName"));

    // now add to car types
    CarTypes ct = CarTypes.instance();
    ct.addName("TestTypeName");
    t.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined after ct",
        false,
        t.acceptsTypeName("TestTypeName"));

    // location must also accept the same type
    l.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined after location",
        true,
        t.acceptsTypeName("TestTypeName"));

    t.deleteTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name deleted", false, t.acceptsTypeName("TestTypeName"));

    /* Needed so later tests will behave correctly */
    ct.deleteName("TestTypeName");

    ct.addName("Baggager");
    t.addTypeName("Baggager");
    l.addTypeName("Baggager");

    Assert.assertEquals(
        "Location Track Accepts Type Name Baggager", true, t.acceptsTypeName("Baggager"));

    /* Test Road Name */
    t.setRoadOption(Track.INCLUDE_ROADS);
    Assert.assertEquals(
        "Location Track set Road Option INCLUDEROADS", "Include", t.getRoadOption());

    Assert.assertEquals(
        "Location Track Accepts Road Name undefined", false, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name defined", true, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestOtherRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name other defined", true, t.acceptsRoadName("TestRoadName"));

    t.deleteRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name deleted", false, t.acceptsRoadName("TestRoadName"));

    t.setRoadOption(Track.ALL_ROADS);
    Assert.assertEquals("Location Track set Road Option AllROADS", "All", t.getRoadOption());
    Assert.assertEquals(
        "Location Track Accepts All Road Names", true, t.acceptsRoadName("TestRoadName"));

    t.setRoadOption(Track.EXCLUDE_ROADS);
    Assert.assertEquals(
        "Location Track set Road Option EXCLUDEROADS", "Exclude", t.getRoadOption());
    Assert.assertEquals(
        "Location Track Excludes Road Names", true, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Excludes Road Names 2", false, t.acceptsRoadName("TestRoadName"));

    /* Test Drop IDs */
    Assert.assertEquals(
        "Location Track Accepts Drop ID undefined", false, t.containsDropId("TestDropId"));

    t.addDropId("TestDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID defined", true, t.containsDropId("TestDropId"));

    t.addDropId("TestOtherDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID other defined", true, t.containsDropId("TestDropId"));

    t.deleteDropId("TestDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID deleted", false, t.containsDropId("TestDropId"));

    /* Test Pickup IDs */
    Assert.assertEquals(
        "Location Track Accepts Pickup ID undefined", false, t.containsPickupId("TestPickupId"));

    t.addPickupId("TestPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID defined", true, t.containsPickupId("TestPickupId"));

    t.addPickupId("TestOtherPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID other defined", true, t.containsPickupId("TestPickupId"));

    t.deletePickupId("TestPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID deleted", false, t.containsPickupId("TestPickupId"));
  }