Ajout de tests sur Panier
This commit is contained in:
parent
fac36fb241
commit
65f4ba4a00
3 changed files with 84 additions and 0 deletions
24
panier/src/test/java/org/example/ComptabiliteTest.java
Normal file
24
panier/src/test/java/org/example/ComptabiliteTest.java
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class ComptabiliteTest {
|
||||||
|
@Test
|
||||||
|
void testTraite() {
|
||||||
|
Comptabilite compta = new Comptabilite("Compta1");
|
||||||
|
|
||||||
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
|
compta.traite("Test Contenu");
|
||||||
|
|
||||||
|
assertEquals("comptabilité:test contenu\n", outContent.toString());
|
||||||
|
|
||||||
|
System.setOut(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
panier/src/test/java/org/example/GestionDeStockTest.java
Normal file
24
panier/src/test/java/org/example/GestionDeStockTest.java
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class GestionDeStockTest {
|
||||||
|
@Test
|
||||||
|
void testTraite() {
|
||||||
|
GestionDeStock stock = new GestionDeStock("Stock1");
|
||||||
|
|
||||||
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
|
stock.traite("Test Contenu");
|
||||||
|
|
||||||
|
assertEquals("G.DES.STOCKS:TEST CONTENU\n", outContent.toString());
|
||||||
|
|
||||||
|
System.setOut(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
panier/src/test/java/org/example/PanierTest.java
Normal file
36
panier/src/test/java/org/example/PanierTest.java
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class PanierTest {
|
||||||
|
@Test
|
||||||
|
void testGetContenu() {
|
||||||
|
GestionDeStock stock = new GestionDeStock("Stock1");
|
||||||
|
Comptabilite compta = new Comptabilite("Compta1");
|
||||||
|
Panier panier = new Panier(stock, compta);
|
||||||
|
|
||||||
|
assertEquals("Contenu du panier", panier.getContenu());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDeclencherCommande() {
|
||||||
|
GestionDeStock stock = new GestionDeStock("Stock1");
|
||||||
|
Comptabilite compta = new Comptabilite("Compta1");
|
||||||
|
Panier panier = new Panier(stock, compta);
|
||||||
|
|
||||||
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
|
panier.declencherCommande();
|
||||||
|
|
||||||
|
String expectedOutput = "G.DES.STOCKS:CONTENU DU PANIER\ncomptabilité:contenu du panier\n";
|
||||||
|
assertEquals(expectedOutput, outContent.toString());
|
||||||
|
|
||||||
|
System.setOut(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue