Hajj-simulation/tests/CampaignTest.java
HeshamTB 8ff0477873
Update CampTest
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.
2020-12-11 17:04:10 +03:00

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);
}
}