package testUnitaire.database.crud.alltest;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;

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

import testUnitaire.database.crud.testCrud;
import database.crud.vente.LocationChambreCrud;
import database.dataset.Location_chambre;

public class testCrudLocation_Chambre extends testCrud<Location_chambre> {

	@Override
	@Before
	public void init() throws SQLException {
		setCrud(new LocationChambreCrud(getConnection()));
		setDataset(new Location_chambre(magicID, Date.valueOf("2013-05-05"), Time.valueOf("10:10:10"), new BigDecimal("1.00"), magicID, magicID, magicID));
		setDataset2(new Location_chambre(magicID+1, Date.valueOf("2013-05-05"), Time.valueOf("10:10:10"), new BigDecimal("1.00"), magicID, magicID, magicID));
	}

	@Test(expected = SQLException.class)  
	public void insertionDuneFKfactureNonValide() throws SQLException {  
		getCrud().create(new Location_chambre(magicID-1, Date.valueOf("2013-05-05"), Time.valueOf("10:10:10"), new BigDecimal("1.00"), magicID+1, magicID, magicID));
	}
	
	@Test(expected = SQLException.class)  
	public void insertionDuneFKarticleNonValide() throws SQLException {  
		getCrud().create(new Location_chambre(magicID-1, Date.valueOf("2013-05-05"), Time.valueOf("10:10:10"), new BigDecimal("1.00"), magicID, magicID+1, magicID));
	}
	
	@Test(expected = SQLException.class)  
	public void insertionDuneFKreservationNonValide() throws SQLException {  
		getCrud().create(new Location_chambre(magicID-1, Date.valueOf("2013-05-05"), Time.valueOf("10:10:10"), new BigDecimal("1.00"), magicID, magicID, magicID+1));
	}
	
	@Test
	public void testDeReadByFkReservation() throws SQLException{
		for (Location_chambre r :((LocationChambreCrud)getCrud()).readByreservation_fk(magicID))
			System.out.println(r.toString());
	}
}
