// 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()); }
public Car copy() { Car car = new Car(); car.setBuilt(_built); car.setColor(_color); car.setLength(_length); car.setLoadName(_loadName); car.setReturnWhenEmptyLoadName(_rweLoadName); car.setNumber(_number); car.setOwner(_owner); car.setRoadName(_road); car.setTypeName(_type); car.loaded = true; return car; }
// test Track pickup support public void testTrackPickUpSupport() { Location l = new Location("Location Test Pickup 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 Pick Ups Start", 0, t.getPickupRS()); Car c1 = new Car("TESTROAD", "TESTNUMBER1"); c1.setLength("40"); t.addPickupRS(c1); Assert.assertEquals("Location Track Pick Ups 1st", 1, t.getPickupRS()); t.addPickupRS(c1); Assert.assertEquals("Location Track Pick Ups 2nd", 2, t.getPickupRS()); t.deletePickupRS(c1); Assert.assertEquals("Location Track Pick Ups 3rd", 1, t.getPickupRS()); t.deletePickupRS(c1); Assert.assertEquals("Location Track Pick Ups 4th", 0, t.getPickupRS()); }
// 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 }