Package dao

Source Code of dao.EpreuveDAOTest

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package dao;

import java.util.List;
import javax.sql.DataSource;
import model.Epreuve;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author Linda
*/
public class EpreuveDAOTest {

    private EpreuveDAO dao = EpreuveDAO.getInstance(new TestDataSource());

    public EpreuveDAOTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getInstance method, of class EpreuveDAO.
     */
//    @Test
//    public void testGetInstance() {
//        System.out.println("getInstance");
//        DataSource ds = null;
//        EpreuveDAO expResult = null;
//        EpreuveDAO result = EpreuveDAO.getInstance(ds);
//        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 getEpreuvesInd method, of class EpreuveDAO.
     */
    @Test
    public void testGetEpreuvesInd() throws Exception {
        System.out.println("getEpreuvesInd");
        String nomD = "Ski Alpin";
        List<Epreuve> result = dao.getEpreuvesInd(nomD);
        assertEquals(10, result.size());
        String[] nomEp = {"Combine", "Descente", "Geant", "Slalom", "Super G"};
        for (int i = 0; i < 5; i++) {
            assertEquals(nomEp[i], result.get(i).getNom());
            assertEquals("feminin", result.get(i).getCategorie().toLowerCase());
            assertEquals(nomEp[i], result.get(i + 5).getNom());
            assertEquals("masculin", result.get(i + 5).getCategorie().toLowerCase());
        }
    }

    /**
     * Test of getEpreuvesEq method, of class EpreuveDAO.
     */
    @Test
    public void testGetEpreuvesEq() throws Exception {
        System.out.println("getEpreuvesEq");
        String nomD = "Bob";
        List<Epreuve> result = dao.getEpreuvesEq(nomD);
        assertEquals(2, result.size());
        String[] nomEp = {"Bob a 4", "Bob a 8"};
        for (int i = 0; i < 2; i++) {
            assertEquals(nomEp[i], result.get(i).getNom());
            assertEquals("masculin", result.get(i).getCategorie().toLowerCase());
        }
    }

    /**
     * Test of getEpreuvesIndBillet method, of class EpreuveDAO.
     */
    @Test
    public void testGetEpreuvesIndBillet() throws Exception {
        System.out.println("getEpreuvesIndBillet");
        String nomD = "Ski Alpin";
        List<Epreuve> result = dao.getEpreuvesIndBillet(nomD);
        assertEquals(1, result.size());

    }

    /**
     * Test of getEpreuvesEqBillet method, of class EpreuveDAO.
     */
    @Test
    public void testGetEpreuvesEqBillet() throws Exception {
        System.out.println("getEpreuvesEqBillet");
        String nomD = "Ski Nordique";
        List<Epreuve> result = dao.getEpreuvesEqBillet(nomD);
        String[] nomEp = {"Biathlon", "Biathlon"};
        assertEquals(2, result.size());
        for (int i = 0; i < 1; i++) {
            assertEquals(nomEp[i], result.get(i).getNom());
            assertEquals("feminin", result.get(i).getCategorie().toLowerCase());
            assertEquals(nomEp[i + 1], result.get(i + 1).getNom());
            assertEquals("masculin", result.get(i + 1).getCategorie().toLowerCase());
        }

    }

    @Test
    public void testGetEpreuveInd() throws Exception {
        Epreuve ep = dao.getEpreuveInd(23);
        assertEquals(23, ep.getId());
        assertEquals("Ski Nordique", ep.getNomD());
        assertEquals("Individuelle", ep.getType());
        assertEquals("Biathlon", ep.getNom());
        assertEquals("feminin", ep.getCategorie());

    }
}
TOP

Related Classes of dao.EpreuveDAOTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.