Ajout de tests sur Panier

This commit is contained in:
Feror 2025-01-30 09:45:14 +01:00
parent fac36fb241
commit 65f4ba4a00
3 changed files with 84 additions and 0 deletions

View 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);
}
}

View 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);
}
}

View 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);
}
}