HeshamTB
8ff0477873
First test is to check set/get and setVehicles(), getVehicles() check if they work correctly. The test is still not completed. Also, added setUp() which is run before every test case.
32 lines
954 B
Java
32 lines
954 B
Java
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);
|
|
}
|
|
}
|