Hajj-simulation/tests/CampaignTest.java

33 lines
938 B
Java
Raw Normal View History

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