Working cucumber tests for sails toggle.

When sails in will send a sails out message when sails out will send a sails in message and then checks for the new status of the sail

#story[1111]
This commit is contained in:
Kusal Ekanayake
2017-08-13 14:55:33 +12:00
parent 2411a3cc2c
commit 25c2de63a2
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -585,7 +585,7 @@ public class Yacht {
this.velocity = velocity; this.velocity = velocity;
updateVelocityProperty(velocity); updateVelocityProperty(velocity);
for (YachtLocationListener yll : locationListeners) { for (YachtLocationListener yll : locationListeners) {
yll.notifyLocation(this, lat, lng, heading, velocity); yll.notifyLocation(this, lat, lng, heading, velocity, clientSailsIn);
} }
} }
+11 -2
View File
@@ -34,8 +34,12 @@ public class ToggleSailSteps {
mst = new MainServerThread(); mst = new MainServerThread();
client = new ClientToServerThread("localhost", 4942); client = new ClientToServerThread("localhost", 4942);
GameState.setCurrentStage(GameStages.RACING); GameState.setCurrentStage(GameStages.RACING);
Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
Assert.assertFalse(yacht.getSailIn());
} }
@When("^the user has pressed \"([^\"]*)\"$") @When("^the user has pressed \"([^\"]*)\"$")
public void the_user_has_pressed(String arg1) throws Throwable { public void the_user_has_pressed(String arg1) throws Throwable {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
@@ -50,7 +54,12 @@ public class ToggleSailSteps {
@Then("^the sails are \"([^\"]*)\"$") @Then("^the sails are \"([^\"]*)\"$")
public void the_sails_are(String arg1) throws Throwable { public void the_sails_are(String arg1) throws Throwable {
//Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
//Assert.assertTrue(yacht.getSailIn()); Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
if (arg1 == "in") {
Assert.assertTrue(yacht.getSailIn());
} else {
Assert.assertFalse(yacht.getSailIn());
}
} }
} }