diff --git a/tests/CampaignTest.java b/tests/CampaignTest.java index 42c3997..6e05d70 100644 --- a/tests/CampaignTest.java +++ b/tests/CampaignTest.java @@ -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 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")); + } }