new tests for camp and street:

One test still fails in camp
This commit is contained in:
HeshamTB 2020-12-11 17:35:41 +03:00
parent 35580a0700
commit 6ffb71154c
Signed by: Hesham
GPG Key ID: 74876157D199B09E
2 changed files with 35 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}