dsfdsf
This commit is contained in:
125
ChasseTresor/test/metier/JoueurTest.java
Normal file
125
ChasseTresor/test/metier/JoueurTest.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit5TestClass.java to edit this template
|
||||
*/
|
||||
package metier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.lalorcey
|
||||
*/
|
||||
public class JoueurTest {
|
||||
|
||||
public JoueurTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test of faireVarierVie method, of class Joueur.
|
||||
*/
|
||||
@Test
|
||||
public void testFaireVarierVie() {
|
||||
System.out.println("--------------------------------faireVarierVie--------------------");
|
||||
Position pos = new Position();
|
||||
Joueur instance = new Joueur("Didier", 5, pos); // <20> compl<70>ter, joueur cr<63><72> avec 5 vies
|
||||
System.out.println ("\t 1er cas : moins 1 vie/5 au d<>part");
|
||||
int nb = -1;
|
||||
instance.faireVarierVie(nb);
|
||||
int expResult = 4; // R<>sultat attendu
|
||||
int result = instance.getNbVie(); // R<>sultat r<>el
|
||||
assertEquals("Pb maj Vie",expResult, result );
|
||||
boolean expResultB = false;
|
||||
boolean resultB = instance.isMort();
|
||||
assertEquals("Pb maj isMort",expResultB, resultB );
|
||||
System.out.println ("\t 2nd cas : moins 6 vies/ 4");
|
||||
Joueur instan = new Joueur("Did", 4, pos);
|
||||
nb = -6;
|
||||
instan.faireVarierVie(nb);
|
||||
expResult = 0;
|
||||
result = instan.getNbVie();
|
||||
assertEquals("Pb maj Vie",expResult, result );
|
||||
expResultB = false;
|
||||
resultB = instance.isMort();
|
||||
assertEquals("Pb maj isMort",expResultB, resultB );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of deplacer method, of class Joueur.
|
||||
*/
|
||||
@Test
|
||||
public void testDeplacer() {
|
||||
System.out.println("--------------------deplacer----------------------");
|
||||
Joueur instance = new Joueur();
|
||||
Position pos1 = new Position(2, 2);
|
||||
instance.setPosition(pos1);
|
||||
|
||||
System.out.println ("\t 1er cas : monter de 1");
|
||||
//Test d'un d<>placement neutre vers le nord
|
||||
Position a = instance.deplacer('n', 3, 3);
|
||||
int expResult = 1;
|
||||
int result = a.getPosY();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
instance.setPosition(a);
|
||||
System.out.println ("\t 2er cas : hors limite vers le nord");
|
||||
a = instance.deplacer('n', 3, 3);
|
||||
instance.setPosition(a);
|
||||
a = instance.deplacer('n', 3, 3);
|
||||
expResult = 0;
|
||||
result = a.getPosY();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
|
||||
System.out.println ("\t 3er cas : Est de 1");
|
||||
a = instance.deplacer('e', 3, 3);
|
||||
expResult = 2;
|
||||
result = a.getPosX();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
instance.setPosition(a);
|
||||
System.out.println ("\t 4er cas : hors limite vers l'Est");
|
||||
a = instance.deplacer('e', 3, 3);
|
||||
instance.setPosition(a);
|
||||
expResult = 2;
|
||||
result = a.getPosX();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
|
||||
System.out.println ("\t 5er cas : Sud de 1");
|
||||
a = instance.deplacer('s', 3, 3);
|
||||
expResult = 1;
|
||||
result = a.getPosY();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
instance.setPosition(a);
|
||||
System.out.println ("\t 6er cas : hors limite vers le Sud");
|
||||
a = instance.deplacer('s', 3, 3);
|
||||
instance.setPosition(a);
|
||||
a = instance.deplacer('s', 3, 3);
|
||||
instance.setPosition(a);
|
||||
expResult = 2;
|
||||
result = a.getPosY();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
|
||||
System.out.println ("\t 7eme cas : Ouest de 1");
|
||||
a = instance.deplacer('o', 3, 3);
|
||||
expResult = 1;
|
||||
result = a.getPosX();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
instance.setPosition(a);
|
||||
System.out.println ("\t 8eme cas : hors limite vers le Sud");
|
||||
a = instance.deplacer('o', 3, 3);
|
||||
instance.setPosition(a);
|
||||
a = instance.deplacer('o', 3, 3);
|
||||
instance.setPosition(a);
|
||||
expResult = 0;
|
||||
result = a.getPosX();
|
||||
assertEquals("Pb d<>placement",expResult, result );
|
||||
//instance.deplacer(direction, nbCol, nbLignes);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
}
|
||||
|
||||
}
|
92
ChasseTresor/test/metier/PositionTest.java
Normal file
92
ChasseTresor/test/metier/PositionTest.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit5TestClass.java to edit this template
|
||||
*/
|
||||
package metier;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.lalorcey
|
||||
*/
|
||||
public class PositionTest {
|
||||
|
||||
public PositionTest() {
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getPosX method, of class Position.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPosX() {
|
||||
System.out.println("getPosX");
|
||||
Position instance = new Position();
|
||||
int expResult = 0;
|
||||
int result = instance.getPosX();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getPosY method, of class Position.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPosY() {
|
||||
System.out.println("getPosY");
|
||||
Position instance = new Position();
|
||||
int expResult = 0;
|
||||
int result = instance.getPosY();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setX method, of class Position.
|
||||
*/
|
||||
@Test
|
||||
public void testSetX() {
|
||||
System.out.println("setX");
|
||||
int x = 0;
|
||||
Position instance = new Position();
|
||||
instance.setX(x);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setY method, of class Position.
|
||||
*/
|
||||
@Test
|
||||
public void testSetY() {
|
||||
System.out.println("setY");
|
||||
int y = 0;
|
||||
Position instance = new Position();
|
||||
instance.setY(y);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of toString method, of class Position.
|
||||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
System.out.println("toString");
|
||||
Position instance = new Position();
|
||||
String expResult = "";
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
}
|
121
ChasseTresor/test/metier/RecifTest.java
Normal file
121
ChasseTresor/test/metier/RecifTest.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
||||
*/
|
||||
package metier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.lalorcey
|
||||
*/
|
||||
public class RecifTest {
|
||||
|
||||
public RecifTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getDangerosite method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDangerosite() {
|
||||
System.out.println("getDangerosite");
|
||||
Recif instance = new Recif();
|
||||
int expResult = 0;
|
||||
int result = instance.getDangerosite();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getLaPosition method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testGetLaPosition() {
|
||||
System.out.println("getLaPosition");
|
||||
Recif instance = new Recif();
|
||||
Position expResult = null;
|
||||
Position result = instance.getLaPosition();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setDangerosite method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testSetDangerosite() {
|
||||
System.out.println("setDangerosite");
|
||||
int dangerosite = 0;
|
||||
Recif instance = new Recif();
|
||||
instance.setDangerosite(dangerosite);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setLaPosition method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testSetLaPosition() {
|
||||
System.out.println("setLaPosition");
|
||||
Position laPosition = null;
|
||||
Recif instance = new Recif();
|
||||
instance.setLaPosition(laPosition);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of toString method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
System.out.println("toString");
|
||||
Recif instance = new Recif();
|
||||
String expResult = "";
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of hashCode method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
System.out.println("hashCode");
|
||||
Recif instance = new Recif();
|
||||
int expResult = 0;
|
||||
int result = instance.hashCode();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of equals method, of class Recif.
|
||||
*/
|
||||
@Test
|
||||
public void testEquals() {
|
||||
System.out.println("equals");
|
||||
Object obj = null;
|
||||
Recif instance = new Recif();
|
||||
boolean expResult = false;
|
||||
boolean result = instance.equals(obj);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
}
|
22
ChasseTresor/test/metier/sqdd.java
Normal file
22
ChasseTresor/test/metier/sqdd.java
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
package metier;
|
||||
|
||||
/**
|
||||
* @author emile malcuit
|
||||
* @version 1
|
||||
*/
|
||||
public class sqdd {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO code application logic here
|
||||
Jeu ju = new Jeu();
|
||||
Position pos = new Position(10, 10);
|
||||
Joueur j = new Joueur("j", 12, pos);
|
||||
Tresor t = new Tresor("coffre", 11, 10);
|
||||
System.out.println(ju.gagner(t, j));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user