new tests for camp and street:
One test still fails in camp
This commit is contained in:
parent
35580a0700
commit
6ffb71154c
@ -51,4 +51,28 @@ public class CampaignTest {
|
||||
assertSame(campaign.getVehicles().get(0).getRoute(), r);
|
||||
assertSame(campaign.getVehicles().get(22).getRoute(), r);
|
||||
}
|
||||
|
||||
@Test
|
||||
void arrivalFunctionsWorkFine() {
|
||||
ArrayList<Vehicle> buses = new ArrayList<>();
|
||||
buses.add(new Bus());
|
||||
buses.add(new Bus());
|
||||
buses.add(new Bus());
|
||||
buses.add(new Bus());
|
||||
Street s = new Street(500, 3, StreetNames.FOURTH_HIGHWAY3);
|
||||
Route r = new Route(s);
|
||||
for (Vehicle v : buses) {
|
||||
((Bus)v).setCampaign(campaign);
|
||||
v.setCurrentStreet(s);
|
||||
v.setRoute(r);
|
||||
}
|
||||
campaign = new Campaign(District.ALAZIZIYA, buses);
|
||||
assertFalse(campaign.isDone());
|
||||
assertEquals(campaign.getNumberOfArrivedBuses(), 0);
|
||||
assertEquals(campaign.getArrivedVehicles().size(), 0);
|
||||
|
||||
campaign.getVehicles().get(0).arrive();//Vehicle notifies camp
|
||||
assertEquals(campaign.getNumberOfArrivedBuses(), 1);
|
||||
assertEquals(campaign.getArrivedVehicles().size(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -46,4 +46,15 @@ class StreetTest {
|
||||
int cars = street.getVehicles().size();
|
||||
assertFalse(canTakeCars);
|
||||
}
|
||||
|
||||
@Test
|
||||
void capacityPointReasonable() {
|
||||
Vehicle v = new Bus();
|
||||
street.addVehicle(v);
|
||||
v.setCurrentStreet(street);
|
||||
v.move(200);
|
||||
//1 is full or crowded
|
||||
assertTrue(street.capcityPoint(0, v.getCurrentLocation()) < 0.8);
|
||||
assertTrue(street.capcityPoint(0, v.getCurrentLocation()) < 0.4);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user