Hajj-simulation/tests/CampaignTest.java

32 lines
954 B
Java
Raw Normal View History

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
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
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);
}
}