package testUnitaire.database.crud.alltest;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.sql.SQLException;

import org.junit.Before;
import org.junit.Test;

import testUnitaire.database.crud.testCrud;
import database.crud.CategorieArticleCrud;
import database.dataset.Categorie_article;

public class testCrudCategorieArticle extends testCrud<Categorie_article> {


	@Override
	@Before
	public void init() throws SQLException {
		setCrud(new CategorieArticleCrud(getConnection()));
		setDataset(new Categorie_article(magicID, "des bons articles"));
		setDataset2(new Categorie_article(magicID+1, "des bons articles"));
	}
	
	@Test
	public void testDeReadAllLike() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Categorie_article a : ((CategorieArticleCrud)getCrud()).readAllLike("bon"))
			ok |= a.equals(getDataset());
		assertTrue("read all like not work",ok);
	}
	
	@Test
	public void testDeReadAllNotLike() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Categorie_article a : ((CategorieArticleCrud)getCrud()).readAllLike("mauvais"))
			ok |= a.equals(getDataset());
		assertFalse("read all like not work",ok);
	}
}
