2020-11-08 07:41:01 +01:00
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
2020-11-07 12:41:55 +01:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
2020-11-09 10:57:33 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2020-11-08 07:41:01 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
2020-11-07 12:41:55 +01:00
|
|
|
|
2020-11-08 07:41:01 +01:00
|
|
|
public class CampaignTest {
|
2020-11-07 12:41:55 +01:00
|
|
|
|
2020-11-08 07:41:01 +01:00
|
|
|
private Campaign campaign;
|
2020-11-07 12:41:55 +01:00
|
|
|
|
2020-11-08 07:41:01 +01:00
|
|
|
@BeforeEach
|
|
|
|
void setUp() {
|
|
|
|
int numberOfBusses = 50;
|
|
|
|
campaign = new Campaign(District.ALAZIZIYA,
|
|
|
|
numberOfBusses);
|
2020-11-07 12:41:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-11-09 10:57:33 +01:00
|
|
|
void VehicleSettersGettersWorkCorrcectly() {
|
|
|
|
ArrayList<Vehicle> oldVehicles = campaign.getVehicles();
|
|
|
|
assertSame(oldVehicles, campaign.getVehicles());
|
|
|
|
ArrayList<Vehicle> newVehicles = new ArrayList<>();
|
2020-11-08 07:41:01 +01:00
|
|
|
for (int i = 0; i < 150; i++) {
|
2020-11-09 10:57:33 +01:00
|
|
|
newVehicles.add(new Bus(5));
|
2020-11-08 07:41:01 +01:00
|
|
|
}
|
|
|
|
campaign.setVehicles(newVehicles);
|
|
|
|
assertNotSame(oldVehicles, newVehicles);
|
|
|
|
assertSame(campaign.getVehicles(), newVehicles);
|
2020-11-07 12:41:55 +01:00
|
|
|
}
|
|
|
|
}
|