package fr.iut.montreuil;
import java.util.Collection;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import fr.iut.montreuil.dao.MediaDao;
import fr.iut.montreuil.model.Media;
public class TestMediaDao
{
private MediaDao dao ;
@Before
public void setup()
{
dao = new MediaDao();
}
@Test
public void list()
{
Collection<Media>medias = dao.findAll();
Assert.assertNotNull(medias);
Assert.assertEquals(0,medias.size());
}
@Test
public void addElement()
{
dao.add(new Media());
Collection<Media>medias = dao.findAll();
Assert.assertNotNull(medias);
Assert.assertEquals(1,medias.size());
}
@Test
public void removeElement()
{
dao.add(new Media("Autant en emporte le vent"));
Collection<Media>medias = dao.findAll();
Assert.assertEquals(1,medias.size());
dao.removeByName("Autant en emporte le vent");
medias = dao.findAll();
Assert.assertNotNull(medias);
Assert.assertEquals(0,medias.size());
}
}