Fixed testing problem where race tests would sometimes fail because a boat did not finish

- Added an option to set the dnf chance, then set it to 0 is all tests

#story[760]
This commit is contained in:
Erika Savell
2017-04-17 15:41:23 +12:00
parent f25e2bac32
commit 4e78ae2ae7
2 changed files with 19 additions and 1 deletions
@@ -31,6 +31,7 @@ public class RaceTest {
Race race = new ConstantVelocityRace(boats, legs, null, 5);
race.disableTimer();
race.setDnfChance(0);
long timeStarted = System.currentTimeMillis();
race.run();
@@ -49,8 +50,10 @@ public class RaceTest {
legs.add(FINISH_LEG);
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs, null, 1);
race.setDnfChance(0);
assertEquals(race.boatsFinished, 0);
race.checkPosition(finishedBoat, 100000);
assertEquals(race.boatsFinished, 1);
assertEquals(finishedBoat.getTimeFinished(), 100000);
@@ -68,6 +71,7 @@ public class RaceTest {
legs.add(FINISH_LEG);
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs, null, 1);
race.setDnfChance(0);
assertEquals(race.boatsFinished, 0);
race.checkPosition(unFinishedBoat, 100);
@@ -84,6 +88,7 @@ public class RaceTest {
legs.add(FINISH_LEG);
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs, null, 1);
race.setDnfChance(0);
BoatInRace unFinishedBoat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
unFinishedBoat.setDistanceTravelledInLeg(100);
@@ -134,6 +139,8 @@ public class RaceTest {
legs.add(START_LEG);
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, scaleFactor);
race.setDnfChance(0);
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);