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.VilleCrud;
import database.dataset.Ville;

public class testCrudVille extends testCrud<Ville> {

	@Override
	@Before
	public void init() throws SQLException{
		setCrud(new VilleCrud(getConnection()));
		setDataset(new Ville(magicID, "crudVille", "crudCounty", "crudLand"));
		setDataset2(new Ville(magicID+1, "crudVille", "crudCounty", "crudLand"));
		System.out.println(getDataset().toString());
	}
	
	@Test
	public void testDeReadAllNotLike() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Ville a : ((VilleCrud)getCrud()).readAllLike("ObjectVille", "", ""))
			ok |= a.equals(getDataset());
		assertFalse("should fail",ok);
	}

	@Test
	public void testDeReadAllLike() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Ville a : ((VilleCrud)getCrud()).readAllLike("crud", "", ""))
			ok |= a.equals(getDataset());
		assertTrue("read all like not work",ok);
	}

	@Test
	public void testDeReadAllLike2() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Ville a : ((VilleCrud)getCrud()).readAllLike("", "crud", ""))
			ok |= a.equals(getDataset());
		assertTrue("read all like not work",ok);
	}

	@Test
	public void testDeReadAllLike3() throws SQLException{
		getCrud().update(getDataset());
		boolean ok=false;
		for (Ville a : ((VilleCrud)getCrud()).readAllLike("", "", "crud"))
			ok |= a.equals(getDataset());
		assertTrue("read all like not work",ok);
	}
}
