Commit dd1249d3 authored by LucasDANIELE's avatar LucasDANIELE
Browse files

Revert "ajout de la librairie pour faciliter la compil"

This reverts commit 212e606b.
parent 212e606b
import fr.insarouen.asi.prog.asiaventure.*;
import fr.insarouen.asi.prog.asiaventure.elements.*;
import fr.insarouen.asi.prog.asiaventure.elements.objets.*;
import fr.insarouen.asi.prog.asiaventure.elements.vivants.*;
import fr.insarouen.asi.prog.asiaventure.elements.structure.*;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@Suite.SuiteClasses({
AllTestAsiaventure.class,
AllTestElements.class,
AllTestVivants.class,
AllTestStructure.class,
AllTestObjets.class
})
public class AllTest{}
......@@ -4,6 +4,8 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.runner.RunWith;
import fr.insarouen.asi.prog.asiaventure.elements.structure.TestPiece;
@RunWith(Suite.class)
@SuiteClasses({
TestPiece.class
......
package fr.insarouen.asi.prog.asiaventure.elements.structure;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.hamcrest.core.IsEqual;
import org.junit.Test;
import fr.insarouen.asi.prog.asiaventure.*;
import fr.insarouen.asi.prog.asiaventure.elements.*;
import fr.insarouen.asi.prog.asiaventure.elements.objets.*;
import fr.insarouen.asi.prog.asiaventure.elements.vivants.*;
import fr.insarouen.asi.prog.asiaventure.elements.structure.*;
import static org.hamcrest.core.AllOf.allOf;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
public class TestPiece{
private Monde monde;
private String nom;
private Piece piece;
@Before
public void init()throws NomDEntiteDejaUtiliseDansLeMondeException, EntiteDejaDansUnAutreMondeException {
monde = new Monde("monde");
nom = "Chambre";
piece = new Piece(monde, nom);
}
@Test(expected = NomDEntiteDejaUtiliseDansLeMondeException.class)
public void creationDoublonPiece() throws NomDEntiteDejaUtiliseDansLeMondeException{
Piece p1 = new Piece(monde, nom);
}
@Test
public void deposerTest() throws NomDEntiteDejaUtiliseDansLeMondeException{
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
piece.deposer(o);
assertThat(piece.contientObjet(o),IsEqual.equalTo(true));
}
@Test
public void retirerTest() throws NomDEntiteDejaUtiliseDansLeMondeException,ObjetAbsentDeLaPieceException,ObjetNonDeplacableException {
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
piece.deposer(o);
assertThat(piece.contientObjet(o),IsEqual.equalTo(true));
piece.retirer(o);
assertThat(piece.contientObjet(o),IsEqual.equalTo(false));
piece.deposer(o);
assertThat(piece.contientObjet(o),IsEqual.equalTo(true));
piece.retirer(o.getNom());
assertThat(piece.contientObjet(o),IsEqual.equalTo(false));
}
@Test
public void contientObjetTest() throws NomDEntiteDejaUtiliseDansLeMondeException, ObjetAbsentDeLaPieceException, ObjetNonDeplacableException{
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
assertThat(piece.contientObjet(o), IsEqual.equalTo(false));
assertThat(piece.contientObjet(o.getNom()), IsEqual.equalTo(false));
piece.deposer(o);
assertThat(piece.contientObjet(o), IsEqual.equalTo(true));
assertThat(piece.contientObjet(o.getNom()), IsEqual.equalTo(true));
piece.retirer(o);
}
@Test
public void getObjets() throws NomDEntiteDejaUtiliseDansLeMondeException{
Objet o1 = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
Objet o2 = new Objet("Masque",monde){
public boolean estDeplacable(){
return true;
}
};
Objet [] o = new Objet[2];
o[0]=o1;
o[1]=o2;
piece.deposer(o1);
piece.deposer(o2);
assertThat(piece.getObjets(),IsEqual.equalTo(o));
}
@Test
public void entrerTest() throws NomDEntiteDejaUtiliseDansLeMondeException, VivantAbsentDeLaPieceException{
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
Vivant v = new Vivant("v", monde, 10, 10, null, o){};
piece.entrer(v);
assertThat(piece.contientVivant(v),IsEqual.equalTo(true));
piece.sortir(v);
}
@Test
public void sortirTest() throws NomDEntiteDejaUtiliseDansLeMondeException,VivantAbsentDeLaPieceException {
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
Vivant v = new Vivant("v", monde, 10, 10, null, o){};
piece.entrer(v);
assertThat(piece.contientVivant(v),IsEqual.equalTo(true));
piece.sortir(v);
assertThat(piece.contientVivant(v),IsEqual.equalTo(false));
piece.entrer(v);
assertThat(piece.contientVivant(v),IsEqual.equalTo(true));
piece.sortir(v.getNom());
assertThat(piece.contientVivant(v),IsEqual.equalTo(false));
}
@Test
public void contientVivantTest() throws NomDEntiteDejaUtiliseDansLeMondeException, VivantAbsentDeLaPieceException{
Objet o = new Objet("GelHydro",monde){
public boolean estDeplacable(){
return true;
}
};
Vivant v = new Vivant("v", monde, 10, 10, null, o){};
assertThat(piece.contientVivant(v),IsEqual.equalTo(false));
assertThat(piece.contientVivant(v.getNom()),IsEqual.equalTo(false));
piece.entrer(v);
assertThat(piece.contientVivant(v),IsEqual.equalTo(true));
assertThat(piece.contientVivant(v.getNom()),IsEqual.equalTo(true));
piece.sortir(v);
}
}
\ No newline at end of file
package fr.insarouen.asi.prog.asiaventure.elements.vivants;
package fr.insarouen.asi.prog.asiaventure.elements.vivants;;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
......
......@@ -54,9 +54,8 @@ public class TestVivant {
assertThat(vivant.getMonde().getNom(), IsEqual.equalTo("monde"));
assertThat(vivant.getPiece(), IsEqual.equalTo("piece"));
assertThat(vivant.getPiece().contientVivant(vivant), IsEqual.equalTo(true));
//assertThat(vivant.getPiece(), IsEqual.equalTo("piece"));
//assertThat(vivant.getPiece().contientVivant(vivant), IsEqual.equalTo(true));
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment