diff --git a/cicaprojekt/Tester.java b/cicaprojekt/Tester.java index 292a08f..70a6d68 100644 --- a/cicaprojekt/Tester.java +++ b/cicaprojekt/Tester.java @@ -21,13 +21,12 @@ public class Tester { Map playerLocations = dungeon.buildDungeon(new File(param)); oneill = new Player("ONeill", (Tile) playerLocations.get("oneill"), Direction.NORTH); jaffa = new Player("Jaffa", (Tile) playerLocations.get("jaffa"), Direction.NORTH); + replicator = new PlayerBase("Replicator", (Tile) playerLocations.get("replicator"), Direction.NORTH); return dungeon; } - void listPlayers() { - System.out.println(oneill); - System.out.println(jaffa); - System.out.println(replicator); + String listPlayers() { + return oneill.toString() + " " + jaffa.toString() + " " + replicator.toString(); } void move(String param) { @@ -132,23 +131,27 @@ public class Tester { } @Test - boolean moveTest(){ - String[] commands = {"loadMap movetest\n", - "listPlayers\n", - "move O", - "listPlayers\n"}; + boolean moveTest() throws IOException{ + boolean succes = true; + + loadMap("moveTest"); - String[] expectedOutputs = {"ONeill: 1,1\n", - "ONeill: 1,2\n"}; + String listOfPlayers = listPlayers(); + if(!listOfPlayers.equals("ONeill: 1, 1 Jaffa: -666, -666 Replicator: -666, -666")) + succes = false; - boolean results = testOnSequenceOfCommands(commands, expectedOutputs); + move("O"); + listOfPlayers = listPlayers(); + if(!listOfPlayers.equals("ONeill: 1, 2 Jaffa: -666, -666 Replicator: -666, -666")) + succes = false; + System.out.print("moveTest: "); - if(results) + if(succes) System.out.println("Sikeres!"); else System.out.println("Sikertelen!"); - return results; + return succes; } @Test @@ -164,6 +167,16 @@ public class Tester { String[] expectedOutputs = {"BlueStargate: 5, 10\n", "YellowStargate: 5, 9\n", "ONeill: 5, 9\n"}; + loadMap("testStargates"); + + shootONeillsGun("B"); + + rotate("O", "L"); + + shootONeillsGun("Y"); + + + boolean results = testOnSequenceOfCommands(commands, expectedOutputs); System.out.print("testStargates: ");