Last active
May 4, 2017 10:47
-
-
Save gonzalezgarciacristian/c5643340de48edab0338b54f868ed155 to your computer and use it in GitHub Desktop.
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
package tests; | |
import static org.junit.Assert.*; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Type; | |
import static org.hamcrest.CoreMatchers.instanceOf; | |
import org.junit.Test; | |
import abstractClasses.Character; | |
import abstractClasses.Enemy; | |
import abstractClasses.Place; | |
import abstractClasses.Player; | |
import exceptions.LocationException; | |
import interfaces.CharacterActions; | |
import models.Archer; | |
import models.City; | |
import models.Forest; | |
import models.NPC; | |
import models.Swordman; | |
import models.Treasure; | |
import models.enemies.Deviling; | |
import utilities.Utilities; | |
import utilities.list.List; | |
import utilities.list.Queue; | |
import utilities.list.Stack; | |
public class Queue2UnitTest { | |
private NPC npc1; | |
private NPC npc2; | |
private Swordman swordman; | |
private Archer archer; | |
private City city; | |
private Forest forest; | |
private Treasure treasure; | |
private List list; | |
private Stack stack; | |
private Deviling deviling; | |
private Queue queue; | |
public Queue2UnitTest() { | |
this.npc1 = new NPC("Blacksmith", 1, 2, "¿Que te arreglo?"); | |
this.npc2 = new NPC("Archer", 3, 4, "¿Quieres flechas?"); | |
this.swordman = new Swordman("Emanie", 5, 5); | |
this.archer = new Archer("Légolas", 3, 2); | |
this.city = new City("Prontera", this.npc1); | |
this.forest = new Forest("Payon", this.npc2); | |
this.treasure = new Treasure(); | |
this.list = new List(); | |
this.stack = new Stack(); | |
this.deviling = new Deviling(5, 4); | |
this.queue = new Queue(); | |
} | |
/** | |
* Test de Clases | |
*/ | |
@Test | |
public void testNPC1() { | |
assertEquals(npc1.getName(), "Blacksmith"); | |
} | |
@Test | |
public void testNPC2() { | |
assertEquals(npc1.getX(), 1); | |
} | |
@Test | |
public void testNPC3() { | |
assertEquals(npc1.getY(), 2); | |
} | |
@Test | |
public void testNPC4() { | |
assertEquals(npc2.getSpeech(), "¿Quieres flechas?"); | |
} | |
@Test | |
public void testPlayer() { | |
assertEquals(swordman.getName(), "Emanie"); | |
} | |
@Test | |
public void testPlace1() { | |
city.setPlayer(swordman); | |
assertEquals(city.getPlayer().getName(), "Emanie"); | |
} | |
@Test | |
public void testPlace2() { | |
forest.setNPC(npc2); | |
NPC npc = forest.getNPC(npc2.getName()); | |
assertEquals(npc.getName(), "Archer"); | |
} | |
@Test | |
public void testPlace3() { | |
assertEquals(city.getName(), "Prontera"); | |
} | |
/** | |
* Test de herencia | |
*/ | |
@Test | |
public void testInstance1() { | |
assertThat(swordman, instanceOf(Character.class)); | |
} | |
@Test | |
public void testInstance2() { | |
assertThat(npc1, instanceOf(Character.class)); | |
} | |
@Test | |
public void testInstance3() { | |
assertThat(city, instanceOf(Place.class)); | |
} | |
@Test | |
public void testInstance4() { | |
assertThat(forest, instanceOf(Place.class)); | |
} | |
/** | |
* Interfaces | |
*/ | |
@Test | |
public void testInterfaces1() { | |
assertTrue(CharacterActions.class.isInterface()); | |
} | |
@Test | |
public void testInterfaces2() { | |
assertFalse(Place.class.isInterface()); | |
} | |
@Test | |
public void testInterfaces3() { | |
assertFalse(Player.class.isInterface()); | |
} | |
@Test | |
public void testInterfaces4() { | |
assertFalse(Archer.class.isInterface()); | |
} | |
@Test | |
public void testInterfaces5() { | |
assertFalse(City.class.isInterface()); | |
} | |
@Test | |
public void testInterfaces6() { | |
assertEquals(swordman.speech(0), "Grrrr"); | |
assertEquals(swordman.speech(1), "Tsk"); | |
assertEquals(swordman.speech(2), "¡Te clavaré mi espada!"); | |
} | |
@Test | |
public void testInterfaces7() { | |
assertEquals(archer.speech(0), "Hola mariposa"); | |
assertEquals(archer.speech(1), "Adiós orco"); | |
assertEquals(archer.speech(2), "¡Flecha va!"); | |
} | |
@Test | |
public void testInterfaces8() { | |
assertEquals(swordman.distance(), 1); | |
} | |
@Test | |
public void testInterfaces9() { | |
assertEquals(archer.distance(), 5); | |
} | |
@Test | |
public void testInterfaces10() { | |
assertEquals(swordman.attack(), 5); | |
} | |
@Test | |
public void testInterfaces11() { | |
assertEquals(archer.attack(), 1); | |
} | |
@Test | |
public void testInterfaces12() { | |
assertThat(swordman, instanceOf(CharacterActions.class)); | |
} | |
@Test | |
public void testInterfaces13() { | |
assertThat(archer, instanceOf(CharacterActions.class)); | |
} | |
/** | |
* Clases abstractas | |
*/ | |
@Test | |
public void testAbstract1() { | |
assertEquals(swordman.walk(), 1); | |
} | |
@Test | |
public void testAbstract2() { | |
assertEquals(archer.walk(), 5); | |
} | |
@Test | |
public void testAbstract3() { | |
assertEquals(npc1.walk(), 0); | |
assertEquals(npc2.walk(), 0); | |
} | |
/** | |
* Sobrecarga de métodos | |
*/ | |
@Test | |
public void testOverload1() { | |
assertNotNull(swordman.speech()); | |
assertNotNull(archer.speech()); | |
} | |
/** | |
* Polimorfismo | |
*/ | |
@Test | |
public void testPolymorphism1() { | |
assertEquals(swordman.getLifePoints(), 100); | |
} | |
@Test | |
public void testPolymorphism2() { | |
assertEquals(archer.getLifePoints(), 60); | |
} | |
@Test | |
public void testPolymorphism3() { | |
assertEquals(swordman.defend(30), 70); | |
assertEquals(swordman.getLifePoints(), 70); | |
} | |
@Test | |
public void testPolymorphism4() { | |
assertEquals(archer.defend(45), 15); | |
assertEquals(archer.getLifePoints(), 15); | |
} | |
/** | |
* Encapsulamiento | |
*/ | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation1() throws NoSuchMethodException { | |
try{ | |
archer.getClass().getMethod("setLifePoints", Integer.class); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation2() throws NoSuchMethodException { | |
try{ | |
swordman.getClass().getMethod("setLifePoints", Integer.class); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation3() throws NoSuchMethodException { | |
try{ | |
archer.getClass().getMethod("setBaseLife"); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation4() throws NoSuchMethodException { | |
try{ | |
swordman.getClass().getMethod("setBaseLife"); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation5() throws NoSuchMethodException { | |
try{ | |
archer.getClass().getMethod("getBaseLife"); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation6() throws NoSuchMethodException { | |
try{ | |
swordman.getClass().getMethod("getBaseLife"); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
@Test(expected=NoSuchMethodException.class) | |
public void testEncapsulation7() throws NoSuchMethodException { | |
try{ | |
Player.class.getMethod("setLifePoints", Integer.class); | |
}catch (SecurityException s) { | |
System.out.println(s.getStackTrace()); | |
} | |
} | |
/** | |
* Propiedad final | |
*/ | |
@Test | |
public void testFinalProperty1() { | |
Field[] declaredFields = Archer.class.getDeclaredFields(); | |
Field finalField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isFinal(field.getModifiers())) { | |
if(field.getName() == "baseLife") | |
finalField = field; | |
} | |
} | |
assertNotNull(finalField); | |
assertTrue(finalField.getName() == "baseLife"); | |
assertTrue(finalField.getType() == int.class); | |
} | |
@Test | |
public void testFinalProperty2() { | |
Field[] declaredFields = Swordman.class.getDeclaredFields(); | |
Field finalField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isFinal(field.getModifiers())) { | |
if(field.getName() == "baseLife") | |
finalField = field; | |
} | |
} | |
assertNotNull(finalField); | |
assertTrue(finalField.getName() == "baseLife"); | |
assertTrue(finalField.getType() == int.class); | |
} | |
@Test | |
public void testFinalProperty3() { | |
Field[] declaredFields = Player.class.getDeclaredFields(); | |
Field finalField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isFinal(field.getModifiers())) { | |
if(field.getName() == "lifePoints") | |
finalField = field; | |
} | |
} | |
assertNull(finalField); | |
} | |
/** | |
* Propiedad static | |
*/ | |
@Test | |
public void testStaticProperty1() { | |
Field[] declaredFields = Archer.class.getDeclaredFields(); | |
Field staticField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { | |
if(field.getName() == "baseLife") | |
staticField = field; | |
} | |
} | |
assertNotNull(staticField); | |
assertTrue(staticField.getName() == "baseLife"); | |
assertTrue(staticField.getType() == int.class); | |
} | |
@Test | |
public void testStaticProperty2() { | |
Field[] declaredFields = Swordman.class.getDeclaredFields(); | |
Field staticField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { | |
if(field.getName() == "baseLife") | |
staticField = field; | |
} | |
} | |
assertNotNull(staticField); | |
assertTrue(staticField.getName() == "baseLife"); | |
assertTrue(staticField.getType() == int.class); | |
} | |
@Test | |
public void testStaticProperty3() { | |
Field[] declaredFields = Player.class.getDeclaredFields(); | |
Field staticField = null; | |
for (Field field : declaredFields) { | |
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { | |
if(field.getName() == "lifePoints") | |
staticField = field; | |
} | |
} | |
assertNull(staticField); | |
} | |
@Test | |
public void testStaticProperty4() { | |
Method[] declaredMethods = Utilities.class.getMethods(); | |
Method staticMethod = null; | |
for (Method method : declaredMethods) { | |
if (java.lang.reflect.Modifier.isStatic(method.getModifiers())) { | |
if(method.getName() == "calculateDamage") | |
staticMethod = method; | |
} | |
} | |
Type[] methodParameters = staticMethod.getGenericParameterTypes(); | |
assertNotNull(staticMethod); | |
assertTrue(staticMethod.getName() == "calculateDamage"); | |
assertTrue(staticMethod.getReturnType() == int.class); | |
assertEquals(methodParameters.length, 2); | |
assertEquals(methodParameters[0].getTypeName(), "int"); | |
assertEquals(methodParameters[1].getTypeName(), "int"); | |
} | |
/** | |
* Excepciones | |
*/ | |
@Test(expected=LocationException.class) | |
public void testException1() throws LocationException { | |
throw new LocationException(); | |
} | |
@Test(expected=LocationException.class) | |
public void testException2() throws LocationException { | |
swordman.walk(5, 5); | |
} | |
@Test(expected=LocationException.class) | |
public void testException3() throws LocationException { | |
archer.walk(3, 2); | |
} | |
@Test | |
public void testException4() { | |
try { | |
swordman.walk(5, 5); | |
// Lanzando la excepción fuerzo a que si no salta lo anterior, salta aquí y falla el test | |
throw new LocationException(); | |
} catch (LocationException e) { | |
assertEquals(e.getMessage(), "Misma X e Y"); | |
} | |
} | |
@Test | |
public void testException5() { | |
try { | |
archer.walk(3, 2); | |
throw new LocationException(); | |
} catch (LocationException e) { | |
assertEquals(e.getMessage(), "Misma X e Y"); | |
} | |
} | |
/** | |
* IO | |
*/ | |
/** | |
* IO-Zip | |
*/ | |
/** | |
* IO-Serialization | |
*/ | |
/** | |
* Arrays | |
*/ | |
@Test | |
public void testTreasure1() { | |
assertTrue(treasure.getX() >= 0 && treasure.getX() <= 10); | |
} | |
@Test | |
public void testTreasure2() { | |
assertTrue(treasure.getY() >= 0 && treasure.getY() <= 10); | |
} | |
@Test | |
public void testTreasure3() { | |
if(treasure.isOpen() && treasure.getWeapon() == null){ | |
assertTrue(true); | |
}else if(treasure.isOpen() && treasure.getWeapon() != null){ | |
assertTrue(false); | |
}else if(!treasure.isOpen() && treasure.getWeapon() != null){ | |
assertTrue(true); | |
}else{ | |
assertTrue(false); | |
} | |
} | |
@Test | |
public void testTreasure4() { | |
assertTrue(city.getTreasures().length == 5); | |
} | |
@Test | |
public void testTreasure5() { | |
assertTrue(city.getTreasures().length == 5); | |
} | |
/** | |
* Lista | |
*/ | |
@Test | |
public void testList1() { | |
assertEquals(0, list.getSize()); | |
assertEquals(list.getHead(), list.getTail()); | |
assertNull(list.getHead()); | |
assertNull(list.getTail()); | |
assertNull(list.getCurrent()); | |
} | |
@Test | |
public void testList2() { | |
list.add(5); | |
assertEquals(1, list.getSize()); | |
assertEquals(list.getHead(), list.getTail()); | |
assertNotNull(list.getHead()); | |
assertNotNull(list.getTail()); | |
} | |
@Test | |
public void testList3() { | |
list.add(5); | |
list.add(3); | |
assertEquals(2, list.getSize()); | |
assertNotEquals(list.getHead(), list.getTail()); | |
assertEquals(5, list.getHead()); | |
assertEquals(3, list.getTail()); | |
} | |
@Test | |
public void testList4() { | |
list.add(5); | |
list.add(3); | |
list.add(7); | |
list.delete(3); | |
assertEquals(2, list.getSize()); | |
assertNotEquals(list.getHead(), list.getTail()); | |
assertEquals(5, list.getHead()); | |
assertEquals(7, list.getTail()); | |
} | |
@Test | |
public void testList5() { | |
assertEquals(0, list.getSize()); | |
list.delete(1); | |
assertEquals(0, list.getSize()); | |
assertEquals(list.getHead(), list.getTail()); | |
assertNull(list.getHead()); | |
assertNull(list.getTail()); | |
} | |
@Test | |
public void testList6() { | |
assertNull(list.getCurrent()); | |
list.add(1); | |
list.add(2); | |
list.add(3); | |
list.add(4); | |
list.add(5); | |
assertNotNull(list.getCurrent()); | |
assertNotNull(list.getHead()); | |
assertEquals(list.getHead(), list.getCurrent()); | |
assertEquals(1, list.getCurrent()); | |
list.next(); | |
assertEquals(2, list.getCurrent()); | |
list.next(); | |
assertEquals(3, list.getCurrent()); | |
list.next(); | |
assertEquals(4, list.getCurrent()); | |
list.next(); | |
assertEquals(5, list.getCurrent()); | |
assertEquals(list.getTail(), list.getCurrent()); | |
list.next(); | |
assertEquals(list.getTail(), list.getCurrent()); | |
} | |
/** | |
* Uso de las listas | |
*/ | |
@Test | |
public void testList21() { | |
city.setNPC(npc2); | |
NPC npc = new NPC("Foodseller", 2, 3, "Tengo carne"); | |
city.setNPC(npc); | |
assertEquals(3, city.getListNPC().getSize()); | |
assertEquals(city.getNPC("Foodseller").getSpeech(), "Tengo carne"); | |
assertEquals(city.getNPC("Archer").getSpeech(), "¿Quieres flechas?"); | |
} | |
@Test | |
public void testList22() { | |
assertEquals(1, forest.getListNPC().getSize()); | |
} | |
@Test | |
public void testList23() { | |
NPC npc = new NPC("Foodseller", 2, 3, "Tengo carne"); | |
List listNPC = new List(); | |
listNPC.add(npc); | |
listNPC.add(npc1); | |
listNPC.add(npc2); | |
City city = new City("Aldebarán", listNPC); | |
assertEquals(3, city.getListNPC().getSize()); | |
} | |
@Test | |
public void testList24() { | |
NPC npc = new NPC("Foodseller", 2, 3, "Tengo carne"); | |
List listNPC = new List(); | |
listNPC.add(npc); | |
listNPC.add(npc1); | |
listNPC.add(npc2); | |
Forest forest = new Forest("Izlude", listNPC); | |
assertEquals(3, forest.getListNPC().getSize()); | |
} | |
/** | |
* Pila | |
*/ | |
@Test | |
public void testStack1() { | |
assertNull(stack.pop()); | |
assertNull(stack.getCurrent()); | |
} | |
@Test | |
public void testStack2() { | |
stack.push(swordman); | |
assertEquals("Emanie", ((Player)stack.getCurrent()).getName()); | |
assertEquals(swordman, stack.getCurrent()); | |
} | |
@Test | |
public void testStack3() { | |
stack.push(swordman); | |
stack.push(archer); | |
stack.push(npc1); | |
assertEquals("¿Que te arreglo?", ((NPC)stack.getCurrent()).getSpeech()); | |
} | |
@Test | |
public void testStack4() { | |
stack.push(npc1); | |
stack.push(swordman); | |
stack.push(archer); | |
assertEquals("Légolas", ((Character)stack.getCurrent()).getName()); | |
assertEquals(archer, stack.pop()); | |
assertEquals("Emanie", ((Character)stack.getCurrent()).getName()); | |
assertEquals(swordman, stack.pop()); | |
assertEquals("Blacksmith", ((Character)stack.getCurrent()).getName()); | |
assertEquals(npc1, stack.pop()); | |
assertNull(stack.pop()); | |
assertNull(stack.getCurrent()); | |
assertNull(stack.pop()); | |
assertNull(stack.getCurrent()); | |
assertNull(stack.pop()); | |
} | |
@Test | |
public void testStack5() { | |
stack.push(archer); | |
assertEquals("Légolas", ((Character)stack.getCurrent()).getName()); | |
assertEquals(archer, stack.pop()); | |
assertNull(stack.pop()); | |
assertNull(stack.getCurrent()); | |
stack.push(npc1); | |
stack.push(swordman); | |
assertEquals("Emanie", ((Character)stack.getCurrent()).getName()); | |
assertEquals(swordman, stack.pop()); | |
assertEquals("Blacksmith", ((Character)stack.getCurrent()).getName()); | |
assertEquals(npc1, stack.pop()); | |
assertNull(stack.pop()); | |
assertNull(stack.getCurrent()); | |
assertNull(stack.pop()); | |
stack.push(archer); | |
assertEquals("Légolas", ((Character)stack.getCurrent()).getName()); | |
} | |
/** | |
* Uso de las pilas | |
*/ | |
@Test | |
public void testDeviling1() { | |
assertEquals(deviling.getName(), "Deviling"); | |
} | |
@Test | |
public void testDeviling2() { | |
assertEquals(deviling.getX(), 5); | |
} | |
@Test | |
public void testDeviling3() { | |
assertEquals(deviling.getY(), 4); | |
} | |
@Test | |
public void testDeviling4() { | |
assertEquals(deviling.getRemainingLife(), 300); | |
} | |
@Test | |
public void testDeviling5() { | |
assertEquals(deviling.walk(), 2); | |
} | |
@Test(expected=NullPointerException.class) | |
public void testDeviling6() throws LocationException { | |
deviling.chase(); | |
} | |
@Test | |
public void testDeviling7() throws LocationException { | |
assertEquals(null, deviling.getCurrentObjective()); | |
deviling.see(swordman); | |
deviling.see(archer); | |
deviling.chase(); | |
assertEquals(archer, deviling.getCurrentObjective()); | |
} | |
@Test | |
public void testDeviling8() throws LocationException { | |
deviling.see(archer); | |
deviling.see(swordman); | |
deviling.chase(); | |
assertEquals(swordman, deviling.getCurrentObjective()); | |
swordman.setX(10); | |
swordman.setY(10); | |
deviling.chase(); | |
assertEquals(archer, deviling.getCurrentObjective()); | |
deviling.see(swordman); | |
archer.setX(5); | |
archer.setY(4); | |
deviling.see(archer); | |
deviling.chase(); | |
assertEquals(archer, deviling.getCurrentObjective()); | |
} | |
@Test(expected=LocationException.class) | |
public void testDeviling9() throws LocationException { | |
deviling.setX(5); | |
deviling.setY(5); | |
deviling.see(swordman); | |
deviling.chase(); | |
} | |
@Test(expected=LocationException.class) | |
public void testDeviling10() throws LocationException { | |
deviling.see(swordman); | |
deviling.chase(); | |
deviling.see(archer); | |
deviling.chase(); | |
deviling.see(swordman); | |
deviling.chase(); | |
deviling.see(swordman); | |
deviling.chase(); | |
} | |
/** | |
* Cola | |
*/ | |
@Test | |
public void testQueue1() { | |
assertTrue(queue.isEmpty()); | |
assertTrue(queue.size() == 0); | |
assertNull(queue.dequeue()); | |
} | |
@Test | |
public void testQueue2() { | |
queue.enqueue(swordman); | |
assertFalse(queue.isEmpty()); | |
assertTrue(queue.size() == 1); | |
Player player = ((Player)(queue.dequeue())); | |
assertEquals("Emanie", player.getName()); | |
assertTrue(queue.isEmpty()); | |
assertTrue(queue.size() == 0); | |
assertNull(queue.dequeue()); | |
} | |
@Test | |
public void testQueue3() { | |
queue.enqueue(swordman); | |
queue.enqueue(archer); | |
queue.enqueue(npc1); | |
assertEquals("Emanie", ((Player)queue.dequeue()).getName()); | |
assertEquals("Légolas", ((Player)queue.dequeue()).getName()); | |
assertEquals("Blacksmith", ((Character)(queue.dequeue())).getName()); | |
assertNull(queue.dequeue()); | |
} | |
@Test | |
public void testQueue4() { | |
queue.enqueue(swordman); | |
queue.enqueue(archer); | |
queue.enqueue(npc1); | |
assertEquals("Emanie", ((Player)queue.dequeue()).getName()); | |
assertEquals("Légolas", ((Player)queue.dequeue()).getName()); | |
queue.enqueue(npc2); | |
assertEquals("Blacksmith", ((Character)(queue.dequeue())).getName()); | |
queue.enqueue(swordman); | |
assertEquals("Archer", ((Character)(queue.dequeue())).getName()); | |
assertEquals("Emanie", ((Character)(queue.dequeue())).getName()); | |
assertNull(queue.dequeue()); | |
assertNull(queue.dequeue()); | |
} | |
/** | |
* Uso de las colas | |
*/ | |
@Test | |
public void testQueue21() { | |
assertNull(swordman.killNextEnemy()); | |
assertTrue(swordman.getEnemiesToKill().isEmpty()); | |
assertEquals(0, swordman.getEnemiesToKill().size()); | |
} | |
@Test | |
public void testQueue22() { | |
archer.addNewEnemy(deviling); | |
assertEquals(1, archer.getEnemiesToKill().size()); | |
Enemy enemy = archer.killNextEnemy(); | |
assertNotNull(enemy); | |
assertEquals(deviling, enemy); | |
assertTrue(archer.getEnemiesToKill().isEmpty()); | |
assertNull(archer.killNextEnemy()); | |
assertTrue(archer.getEnemiesToKill().isEmpty()); | |
assertEquals(0, archer.getEnemiesToKill().size()); | |
assertEquals(null, archer.killNextEnemy()); | |
assertNull(swordman.killNextEnemy()); | |
assertTrue(swordman.getEnemiesToKill().isEmpty()); | |
assertEquals(0, swordman.getEnemiesToKill().size()); | |
assertEquals(null, swordman.killNextEnemy()); | |
} | |
@Test | |
public void testQueue23() { | |
Deviling deviling2 = new Deviling(0, 0); | |
Deviling deviling3 = new Deviling(1, 1); | |
Deviling deviling4 = new Deviling(2, 2); | |
swordman.addNewEnemy(deviling); | |
swordman.addNewEnemy(deviling2); | |
swordman.addNewEnemy(deviling3); | |
swordman.addNewEnemy(deviling4); | |
assertEquals(deviling, swordman.killNextEnemy()); | |
assertEquals(deviling2, swordman.killNextEnemy()); | |
assertEquals(deviling3, swordman.killNextEnemy()); | |
assertEquals(deviling4, swordman.killNextEnemy()); | |
assertNull(swordman.killNextEnemy()); | |
} | |
@Test | |
public void testQueue24() { | |
Deviling deviling2 = new Deviling(0, 0); | |
Deviling deviling3 = new Deviling(1, 1); | |
Deviling deviling4 = new Deviling(2, 2); | |
Deviling deviling5 = new Deviling(3,3); | |
swordman.addNewEnemy(deviling); | |
swordman.addNewEnemy(deviling2); | |
archer.addNewEnemy(deviling3); | |
archer.addNewEnemy(deviling4); | |
assertEquals(deviling, swordman.killNextEnemy()); | |
assertEquals(deviling3, archer.killNextEnemy()); | |
swordman.addNewEnemy(deviling5); | |
assertEquals(deviling2, swordman.killNextEnemy()); | |
assertEquals(deviling4, archer.killNextEnemy()); | |
assertEquals(deviling5, swordman.killNextEnemy()); | |
assertEquals(null, archer.killNextEnemy()); | |
assertEquals(null, swordman.killNextEnemy()); | |
assertEquals(null, archer.killNextEnemy()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment