New test for Camp:

- test UID
	- test generateBusses()
	- test Constructor with (Dist, numberOFBusses)
This commit is contained in:
HeshamTB 2020-11-09 13:22:35 +03:00
parent df214053bd
commit 58ed0a5df8
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -3,8 +3,7 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.*;
public class CampaignTest {
@ -29,4 +28,35 @@ public class CampaignTest {
assertNotSame(oldVehicles, newVehicles);
assertSame(campaign.getVehicles(), newVehicles);
}
@Test
void GenerateBussesToSameValAsParam() {
campaign.generateBusses(50);
assertEquals(campaign.getVehicles().size(), 50);
}
@Test
void ConstructorWithNumberOfBusses() {
campaign = new Campaign(District.ALAZIZIYA, 60);
assertNotNull(campaign.getVehicles());
ArrayList<Vehicle> list = new ArrayList<>();
list.add(new Bus(5));
list.add(new Bus(7));
campaign = new Campaign(District.ALAZIZIYA, list);
assertNotNull(campaign.getVehicles());
}
/*
This test depends on order of tests in this file.
It tests a var related to a static member.
The Junit way is to run setUp() for every test case;
thus, making the static car count up to how many times
the object is constructed.
*/
@Test
void UID_AsExpected(){
String uid = campaign.getUID();
assertTrue(campaign.getUID().matches("CAMP0006"));
}
}