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-08 07:41:01 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
|
|
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-08 07:41:01 +01:00
|
|
|
void AllSettersGettersWorkCorrcectly() {
|
|
|
|
Object[] oldVehicles = campaign.getVehicles();
|
|
|
|
assertArrayEquals(campaign.getVehicles(), oldVehicles);
|
|
|
|
Vehicle[] newVehicles = new Bus[150];
|
|
|
|
for (int i = 0; i < 150; i++) {
|
|
|
|
newVehicles[i] = new Bus(5);
|
|
|
|
}
|
|
|
|
campaign.setVehicles(newVehicles);
|
|
|
|
assertNotSame(oldVehicles, newVehicles);
|
|
|
|
assertSame(campaign.getVehicles(), newVehicles);
|
2020-11-07 12:41:55 +01:00
|
|
|
}
|
|
|
|
}
|