/*
 * 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 métiers;

import java.util.HashMap;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author famille Thevenot
 */
public class CommandeTest {
    
    public CommandeTest() {
    }
    
    @Before
    public void setUp() {
    }

    /**
     * Test of ajouter method, of class Commande.
     */
    @Test
    public void testAjouter() {
         Instrument instr1=new Instrument(1,"Piano",10, 8300f);
          Instrument instr2=new Instrument(2,"Violon",9, 105f);
          Commande laCommande = new Commande(1,1,"12/09/2024");
        System.out.println("ajouter");
       //cas 0
       boolean ajoutRes= laCommande.ajouter(instr1, 2);
       boolean ajoutAttendu = true;
        System.out.println("cas0 : cas normal, ajout une ligne de commande");
       assertEquals("Test0 ajout 2 instr1",ajoutAttendu,ajoutRes);
       int stockRes=instr1.getQteStock();
       int stockAttendu=8;
       assertEquals("Test0 stock",stockAttendu,stockRes);
       int qteRes=laCommande.getLesLignes().get(instr1);
       int qteAttendu=2;
       assertEquals("Test0 quantite",qteRes, qteAttendu);
       
        //cas 1
       System.out.println("Cas1 : ajout autre ligne de commande");
       laCommande.ajouter(instr2, 6);
       int tailleR=laCommande.getLesLignes().size();
       int tailleAttendue=2;
       assertEquals("Test1 taille",tailleAttendue,tailleR);
       
       //Cas2
       System.out.println("Cas2 : màj quantité commandée d'une ligne existante");
       laCommande.ajouter(instr2, 5);
       stockRes=instr2.getQteStock();
       stockAttendu=4;
       assertEquals("test2 stock",stockAttendu,stockRes );
       
       qteRes=laCommande.getLesLignes().get(instr2);
       qteAttendu=5;
       assertEquals("Test2 quantite", qteAttendu,qteRes);
       
        /*INES*/
        System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock");
        /*MAISSANE*/
        System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0");
        /*MORGANN*/ 
        System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante");
        /*INES*/
        System.out.println("Cas6 : màj d'une ligne existante avec qté>stock");
    }

        
    /**
     * Test of supprimer method, of class Commande.
     
    @Test
    public void testSupprimer() {
        System.out.println("supprimer");
        Instrument unInstrument = null;
        Commande instance = null;
        boolean expResult = false;
        boolean result = instance.supprimer(unInstrument);
        assertEquals("test supprimer",expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }*/

}