-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Közös munka IntelliJ-ben Code With Me funkcióval. Résztvevők: Karsai Artúr Sinkler Szilveszter
- Loading branch information
Showing
9 changed files
with
280 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cucumberTest; | ||
|
||
import drukmakoriSzerelok.Game; | ||
import drukmakoriSzerelok.Tank; | ||
import drukmakoriSzerelok.Fixer; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FixerActionsOnTank { | ||
private Tank tank = new Tank(); | ||
private Fixer fixer = new Fixer("fixer1",""); | ||
|
||
public FixerActionsOnTank(){ | ||
Game.Get().SetActivePlayer(fixer); | ||
} | ||
|
||
@Given("a tank") | ||
public void a_tank() { | ||
Game game = Game.Get(); | ||
} | ||
|
||
@Given("the fixer currently standing on that tank") | ||
public void the_fixer_currently_standing_on_that_tank() { | ||
fixer.SetField(tank); | ||
tank.AddPlayer(fixer); | ||
} | ||
|
||
@When("the saboteur tries to carry a pipe") | ||
public void the_saboteur_tries_to_carry_a_pipe() { | ||
fixer.CarryPipe(tank); | ||
} | ||
|
||
@When("the saboteur tries to carry a pump") | ||
public void the_saboteur_tries_to_carry_a_pump() { | ||
fixer.CarryPump(tank); | ||
} | ||
|
||
@Then("the tank should have {string} pipes") | ||
public void the_tank_should_have_pipes(String answer){ | ||
assertEquals(answer, String.valueOf(tank.getNumberOfPipes())); | ||
} | ||
|
||
@Then("the tank should have {string} pumps") | ||
public void the_tank_should_have_pumps(String answer){ | ||
assertEquals(answer, String.valueOf(tank.getNumberOfPumps())); | ||
} | ||
|
||
@Then("the fixer should {string}have an active field") | ||
public void the_fixer_should_have_an_active_field(String answer){ | ||
var result = fixer.GetHasActive() ? "" : "not "; | ||
assertEquals(answer, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package cucumberTest; | ||
|
||
import drukmakoriSzerelok.*; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class PlayerMoves{ | ||
Field tank; | ||
Player player; | ||
Field neighbour; | ||
|
||
@Given("a default map") | ||
public void a_default_map() { | ||
Game.Get(); | ||
} | ||
@Given("a fixer currently standing on a tank") | ||
public void a_fixer_currently_standing_on_a_tank() { | ||
player = Game.Get().GetPlayers().get(0); | ||
Game.Get().SetActivePlayer(player); | ||
tank = player.GetField(); | ||
} | ||
@Given("a neighbour pipe") | ||
public void a_neighbour_pipe() { | ||
neighbour = Game.Get().GetMap().GetNeighbourFromDirection(tank, "right"); | ||
} | ||
@When("the fixer tries to move to the neighbour pipe") | ||
public void the_fixer_tries_to_move_to_the_neighbour_pipe() { | ||
player.Move(neighbour); | ||
} | ||
@Then("the fixer should be placed on the {string} pipe") | ||
public void the_fixer_should_be_placed_on_the_neighbour_pipe(String answer) { | ||
var result = player.GetField() == neighbour ? "neighbour" : "tank"; | ||
assertEquals(answer, result); | ||
} | ||
|
||
|
||
Field field1; | ||
Field field2; | ||
Player player1; | ||
Player player2; | ||
Field pump; | ||
|
||
@Given("two players currently standing on two separate fields") | ||
public void two_players_currently_standing_on_two_separate_fields() { | ||
player1 = Game.Get().GetPlayers().get(0); | ||
player2 = Game.Get().GetPlayers().get(1); | ||
field1 = player1.GetField(); | ||
field2 = Game.Get().GetMap().GetNeighbourFromDirection(Game.Get().GetMap().GetNeighbourFromDirection(field1, "right"), "right"); | ||
field2.AddPlayer(player2); | ||
player2.SetField(field2); | ||
} | ||
@Given("a neighbour pump") | ||
public void a_neighbour_pump() { | ||
pump = Game.Get().GetMap().GetNeighbourFromDirection(field1, "left"); | ||
pump = new Pump(); | ||
} | ||
@When("both players try to move to the neighbour pump") | ||
public void both_players_try_to_move_to_the_neighbour_pump() { | ||
Game.Get().SetActivePlayer(player1); | ||
player1.Move(pump); | ||
Game.Get().SetActivePlayer(player2); | ||
player2.Move(pump); | ||
} | ||
@Then("{string} players should be placed on the pump") | ||
public void both_players_should_be_placed_on_the_pump(String answer) { | ||
String result = String.valueOf(pump.GetPlayer().size()); | ||
assertEquals(answer, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package cucumberTest; | ||
|
||
import drukmakoriSzerelok.Saboteur; | ||
import drukmakoriSzerelok.Game; | ||
import drukmakoriSzerelok.Pipe; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
class IsPipeStatusCorrect { | ||
static String isItSlippery(boolean status) { | ||
return status ? "" : "not "; | ||
} | ||
|
||
static String isItSticky(boolean status) { return status ? "" : "not "; } | ||
} | ||
|
||
public class SaboteurActionsOnPipe { | ||
private Pipe pipe = new Pipe(); | ||
private Saboteur saboteur = new Saboteur("saboteur1",""); | ||
|
||
private boolean result; | ||
|
||
public SaboteurActionsOnPipe(){ | ||
Game.Get().SetActivePlayer(saboteur); | ||
} | ||
|
||
@Given("a not broken pipe") | ||
public void a_not_broken_pipe() { | ||
pipe.SetIsBroken(false); | ||
Game game = Game.Get(); | ||
} | ||
|
||
@Given("the saboteur currently standing on that pipe") | ||
public void the_saboteur_currently_standing_on_that_pipe() { | ||
saboteur.SetField(pipe); | ||
pipe.AddPlayer(saboteur); | ||
} | ||
|
||
@When("the saboteur tries to break that") | ||
public void the_saboteur_tries_to_break_that() { | ||
saboteur.PipeSabotage(pipe); | ||
result = ! pipe.GetIsBroken(); | ||
} | ||
|
||
@Given("a pipe") | ||
public void a_pipe() { | ||
Game game = Game.Get(); | ||
} | ||
|
||
@When("the saboteur tries to make that slippery") | ||
public void the_saboteur_tries_to_make_that_slippery() { | ||
saboteur.MakeSlippery(pipe); | ||
result = pipe.GetSlippery() > 0; | ||
} | ||
|
||
@When("the saboteur tries to make that sticky") | ||
public void the_saboteur_tries_to_make_that_sticky() { | ||
saboteur.MakeSticky(pipe); | ||
result = pipe.GetSticky() > 0; | ||
} | ||
|
||
@Then("the pipe should be {string}slippery") | ||
public void the_pipe_should_be_slippery(String answer){ | ||
assertEquals(answer, IsPipeStatusCorrect.isItSlippery(result)); | ||
} | ||
|
||
@Then("the pipe should be {string}sticky") | ||
public void the_pipe_should_be_sticky(String answer){ | ||
assertEquals(answer, IsPipeStatusCorrect.isItSticky(result)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/cucumberTest/FixerActionsOnTank.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: | ||
Scenario: test carrying pipe | ||
Given a tank | ||
Given the fixer currently standing on that tank | ||
When the saboteur tries to carry a pipe | ||
Then the tank should have "4" pipes | ||
Then the fixer should ""have an active field | ||
|
||
Scenario: test carrying pump | ||
Given a tank | ||
Given the fixer currently standing on that tank | ||
When the saboteur tries to carry a pump | ||
Then the tank should have "0" pumps | ||
Then the fixer should ""have an active field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
Feature: test fixing the pipe and pump | ||
Scenario: | ||
Feature: | ||
Scenario: test fixing a pipe | ||
Given a broken pipe | ||
Given the fixer currently standing on that pipe | ||
When the fixer try to repair that | ||
When the fixer tries to repair that | ||
Then it should be "fixed" | ||
|
||
Scenario: test fixing a pump | ||
Given a broken pump | ||
Given the fixer currently standing on that pump | ||
When the fixer tries to repair that | ||
Then it should be "fixed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: | ||
Scenario: a player moves to another pipe | ||
Given a default map | ||
And a fixer currently standing on a tank | ||
And a neighbour pipe | ||
When the fixer tries to move to the neighbour pipe | ||
Then the fixer should be placed on the "neighbour" pipe | ||
|
||
Scenario: two players move to the same pump | ||
Given a default map | ||
And two players currently standing on two separate fields | ||
And a neighbour pump | ||
When both players try to move to the neighbour pump | ||
Then "2" players should be placed on the pump |
18 changes: 18 additions & 0 deletions
18
src/test/resources/cucumberTest/SaboteurActionsOnPipe.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: | ||
Scenario: test breaking a pipe | ||
Given a not broken pipe | ||
Given the saboteur currently standing on that pipe | ||
When the saboteur tries to break that | ||
Then it should be "broken" | ||
|
||
Scenario: test making a pipe slippery | ||
Given a pipe | ||
Given the saboteur currently standing on that pipe | ||
When the saboteur tries to make that slippery | ||
Then the pipe should be ""slippery | ||
|
||
Scenario: test making a pipe sticky | ||
Given a pipe | ||
Given the saboteur currently standing on that pipe | ||
When the saboteur tries to make that sticky | ||
Then the pipe should be ""sticky |