-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug with ConnectPipe and done more tests
- Loading branch information
1 parent
4bfbfd8
commit 1af1964
Showing
11 changed files
with
343 additions
and
37 deletions.
There are no files selected for viewing
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
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,24 +1,43 @@ | ||
package HwProject.tests.HelperClasses; | ||
|
||
import HwProject.src.Pipe; | ||
|
||
/** | ||
* Pipe subclass for testing, only added setters and getters for each private and protected field | ||
*/ | ||
public class TestPipe extends Pipe { | ||
public TestPipe() { | ||
super(); | ||
} | ||
|
||
public int getWaterLevel() { | ||
return waterLevel; | ||
} | ||
|
||
public void setWaterLevel(int waterLevel) { | ||
this.waterLevel = waterLevel; | ||
} | ||
|
||
public static void setInstanceNr(int i) { | ||
instanceNr = i; | ||
} | ||
} | ||
package tests.HelperClasses; | ||
|
||
import src.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
/** | ||
* Pipe subclass for testing, only added setters and getters for each private and protected field | ||
*/ | ||
public class TestPipe extends Pipe { | ||
public TestPipe() { | ||
super(); | ||
} | ||
|
||
public int getWaterLevel() { | ||
return waterLevel; | ||
} | ||
|
||
public void setWaterLevel(int waterLevel) { | ||
this.waterLevel = waterLevel; | ||
} | ||
|
||
public boolean getSplippy() { | ||
return this.isSlippy; | ||
} | ||
|
||
public StickyStates getSticky() { | ||
return this.stickyState; | ||
} | ||
|
||
public static void setInstanceNr(int i) { | ||
instanceNr = i; | ||
} | ||
|
||
public ArrayList<Player> getPlayers() { | ||
return players; | ||
} | ||
|
||
public boolean getDamage() { | ||
return isDamaged; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,81 @@ | ||
package src; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import tests.HelperClasses.TestCleanup; | ||
import tests.HelperClasses.TestSaboteur; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class SaboteurTest { | ||
private Game game; | ||
|
||
private TestSaboteur saboteur; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
game = new Game(System.out); | ||
Pipe.SetGame(game); | ||
Drain.SetGame(game); | ||
saboteur = new TestSaboteur("Saboteur1", game.GetFieldByID("Drain1")); | ||
} | ||
|
||
@Test | ||
void move() { | ||
saboteur.Move(game.GetFieldByID("Pipe12")); | ||
assertEquals(game.GetFieldByID("Pipe12"), saboteur.getPosition()); | ||
|
||
TestSaboteur saboteur2 = new TestSaboteur("Saboteur2", game.GetFieldByID("Drain1")); | ||
saboteur2.Move(game.GetFieldByID("Pipe12")); | ||
assertEquals(game.GetFieldByID("Drain1"), saboteur2.getPosition()); | ||
} | ||
|
||
@Test | ||
void setPumpDirection() { | ||
saboteur.Move(game.GetFieldByID("Pipe12")); | ||
saboteur.Move(game.GetFieldByID("Pump5")); | ||
saboteur.SetPumpDirection((Pipe) game.GetFieldByID("Pipe3"), (Pipe) game.GetFieldByID("Pipe10")); | ||
assertEquals(game.GetFieldByID("Pipe10"), ((Pump) game.GetFieldByID("Pump5")).output); | ||
assertEquals(game.GetFieldByID("Pipe3"), ((Pump) game.GetFieldByID("Pump5")).input); | ||
} | ||
|
||
@Test | ||
void damage() { | ||
saboteur.Move(game.GetFieldByID("Pipe12")); | ||
saboteur.Damage(); | ||
assertTrue(((Pipe) game.GetFieldByID("Pipe12")).isDamaged); | ||
} | ||
|
||
@Test | ||
void makeSlippy() { | ||
saboteur.Move(game.GetFieldByID("Pipe12")); | ||
saboteur.MakeSlippy(); | ||
assertTrue(((Pipe) game.GetFieldByID("Pipe12")).isSlippy); | ||
} | ||
|
||
@Test | ||
void makeSticky() { | ||
} | ||
|
||
@Test | ||
void testSetPumpDirection() { | ||
} | ||
|
||
@Test | ||
void testDamage() { | ||
} | ||
|
||
@Test | ||
void testMakeSlippy() { | ||
} | ||
|
||
@Test | ||
void testMakeSticky() { | ||
} | ||
|
||
@AfterEach | ||
public void cleanUp() { | ||
TestCleanup.cleanup(); | ||
} | ||
} |
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,11 @@ | ||
package tests.HelperClasses; | ||
|
||
public class TestCleanup { | ||
|
||
public static void cleanup() { | ||
TestPump.setInstanceNr(0); | ||
TestPipe.setInstanceNr(0); | ||
TestSource.setInstanceNr(0); | ||
TestDrain.setInstanceNr(0); | ||
} | ||
} |
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,12 @@ | ||
package tests.HelperClasses; | ||
import src.*; | ||
public class TestSaboteur extends Saboteur { | ||
|
||
public TestSaboteur(String ID, Field position) { | ||
super(ID, position); | ||
} | ||
|
||
public Field getPosition() { | ||
return position; | ||
} | ||
} |
Oops, something went wrong.