Tester methods modified
This commit is contained in:
parent
b37606b86f
commit
848350394f
@ -43,7 +43,7 @@ public class Tester {
|
||||
}
|
||||
}
|
||||
|
||||
void boxLift(String param) {
|
||||
String boxLift(String param) {
|
||||
switch (param) {
|
||||
case "O" :
|
||||
oneill.boxLift();
|
||||
@ -52,9 +52,10 @@ public class Tester {
|
||||
jaffa.boxLift();
|
||||
break;
|
||||
}
|
||||
return "box lifted";
|
||||
}
|
||||
|
||||
void boxDrop(String param) {
|
||||
String boxDrop(String param) {
|
||||
switch (param) {
|
||||
case "O" :
|
||||
oneill.boxDrop();
|
||||
@ -63,6 +64,7 @@ public class Tester {
|
||||
oneill.boxDrop();
|
||||
break;
|
||||
}
|
||||
return "box dropped";
|
||||
}
|
||||
|
||||
void shootONeillsGun(String param) {
|
||||
@ -76,26 +78,29 @@ public class Tester {
|
||||
}
|
||||
}
|
||||
|
||||
void rotate(String playerParam, String directionParam) {
|
||||
String rotate(String playerParam, String directionParam) {
|
||||
switch (playerParam) {
|
||||
case "O" :
|
||||
switch (directionParam) {
|
||||
case "L" :
|
||||
oneill.rotateLeft();
|
||||
break;
|
||||
return oneill.getFacingDirection().toString();
|
||||
case "R" :
|
||||
oneill.rotateRight();
|
||||
break;
|
||||
return oneill.getFacingDirection().toString();
|
||||
default: return "Hiba, nem fordult!";
|
||||
}
|
||||
case "J" :
|
||||
switch (directionParam) {
|
||||
case "L" :
|
||||
jaffa.rotateLeft();
|
||||
break;
|
||||
return jaffa.getFacingDirection().toString();
|
||||
case "R" :
|
||||
jaffa.rotateRight();
|
||||
break;
|
||||
return jaffa.getFacingDirection().toString();
|
||||
default: return "Hiba, nem fordult!";
|
||||
}
|
||||
default: return "Hiba, nem létező játékos!";
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,6 +113,12 @@ public class Tester {
|
||||
return blue + " " + yellow + " " + red + " " + green;
|
||||
}
|
||||
|
||||
String getConnectedGateOpen(Scale s){
|
||||
if(s.getGateConnected().isOpen())
|
||||
return "gate open";
|
||||
else return "gate closed";
|
||||
}
|
||||
|
||||
/* custom Test annotation */
|
||||
@Target(ElementType.METHOD) // it's for methods
|
||||
@Retention(RetentionPolicy.RUNTIME) // we want to retain annotations in runtime
|
||||
@ -134,31 +145,31 @@ public class Tester {
|
||||
|
||||
@Test
|
||||
boolean moveTest() throws IOException{
|
||||
boolean succes = true;
|
||||
boolean success = true;
|
||||
|
||||
loadMap("moveTest");
|
||||
|
||||
String listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 1, 1 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
succes = false;
|
||||
success = false;
|
||||
|
||||
move("O");
|
||||
|
||||
listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 1, 2 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
succes = false;
|
||||
success = false;
|
||||
|
||||
System.out.print("moveTest: ");
|
||||
if(succes)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return succes;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testStargates() throws IOException{
|
||||
boolean succes = true;
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testStargates");
|
||||
shootONeillsGun("B");
|
||||
@ -167,7 +178,7 @@ public class Tester {
|
||||
|
||||
String listOfStargates = listStargates();
|
||||
if(!listOfStargates.equals("BlueStargate: 5, 10 YellowStargate: 10, 5 RedStargate: not spawned GreenStargate: not spawned"))
|
||||
succes = false;
|
||||
success = false;
|
||||
|
||||
move("O");
|
||||
move("O");
|
||||
@ -175,95 +186,70 @@ public class Tester {
|
||||
|
||||
String listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 5, 9 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
succes = false;
|
||||
success = false;
|
||||
|
||||
System.out.print("testStargates: ");
|
||||
if(succes)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return succes;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testExtraZPM(){
|
||||
String[] commands = {"loadMap testExtraZPMs\n",
|
||||
"listZPMs\n",
|
||||
"move O\n",
|
||||
"move O\n",
|
||||
"listZPMs\n"};
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
|
||||
loadMap("testExtraZPMs");
|
||||
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
System.out.print("testExtraZPMs: ");
|
||||
if(results)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
boolean testScalesAndGates() throws IOException {
|
||||
boolean succes = true;
|
||||
|
||||
String[] commands = {"loadMap testScalesAndGates\n",
|
||||
"boxLift O\n",
|
||||
"rotate O L\n",
|
||||
"boxDrop O\n"};
|
||||
|
||||
String[] expectedOutputs = {"door open\n"};
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testScalesAndGates");
|
||||
boxLift("O");
|
||||
rotate("O", "L");
|
||||
boxDrop("O");
|
||||
|
||||
String gateOpen = getConnectedGateOpen((Scale)oneill.getCurrentTile().getAdjacentTile(oneill.facingDirection));
|
||||
|
||||
if(!gateOpen.equals("gate open"))
|
||||
success = false;
|
||||
|
||||
System.out.print("testScalesAndGates: ");
|
||||
if(succes)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return succes;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean gapTest(){
|
||||
String[] commands = {"loadMap gapTest\n",
|
||||
"move O\n"};
|
||||
boolean gapTest() throws IOException{
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
loadMap("gapTest");
|
||||
move("O");
|
||||
|
||||
boolean success = oneill.isDestroyed();
|
||||
|
||||
System.out.print("gapTest: ");
|
||||
if(results)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean ZPMTest() throws IOException{
|
||||
boolean succes = true;
|
||||
|
||||
String[] commands = {"loadMap ZPMTest\n",
|
||||
"move O\n"};
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
boolean success = true;
|
||||
|
||||
loadMap("ZPMTest");
|
||||
move("O");
|
||||
|
||||
if(oneill.getZPMCount() != 1)
|
||||
success = false;
|
||||
|
||||
System.out.print("ZPMTest: ");
|
||||
if(succes)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return succes;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -299,33 +285,46 @@ public class Tester {
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean rotationTest() {
|
||||
String[] commands = {"loadMap rotationTest\n",
|
||||
"Rotate O L\n",
|
||||
"Rotate O R\n"};
|
||||
boolean rotationTest() throws IOException {
|
||||
boolean success = true;
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
loadMap("rotationTest");
|
||||
|
||||
if(!rotate("O", "L").equals("WEST"))
|
||||
success = false;
|
||||
|
||||
if(!rotate("O", "R").equals("NORTH"))
|
||||
success = false;
|
||||
|
||||
System.out.print("rotationTest: ");
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testBoxes(){
|
||||
String[] commands = {"loadMap testBoxes\n",
|
||||
"boxLift\n",
|
||||
"boxDrop\n"};
|
||||
|
||||
String[] expectedOutputs = {"boc3 lifted\n",
|
||||
"box3 dropped\n"};
|
||||
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
System.out.print("testBoxes: ");
|
||||
if(results)
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
return success;
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testBoxes() throws IOException{
|
||||
boolean success = true;
|
||||
|
||||
loadMap("testBoxes");
|
||||
|
||||
if(!boxLift("O").equals("box lifted"))
|
||||
success = false;
|
||||
|
||||
if(!boxDrop("O").equals("box dropped"))
|
||||
success = false;
|
||||
|
||||
System.out.print("testBoxes: ");
|
||||
if(success)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user