package dao;

import static org.junit.Assert.assertTrue;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

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

import util.DBConexao;
import util.DBConfig;

import dao.SalaDAO;

import business.Sala;

public class SalaDaoTestCase {
	Sala sala = new Sala();
	SalaDAO salaDao = null;

	@Before
	public void setUp() throws Exception {
		Properties properties = new Properties();
		try {
			properties.load(new FileInputStream("./dbconfig.properties"));
		} catch (IOException e) {
			System.out.println("Arquivo de properties não encontrado");
			e.printStackTrace();
			System.exit(1);
		}

		DBConfig dbConfig = new DBConfig();

		dbConfig.setConfiguracao(properties);

		DBConexao db = DBConexao.getInstance(dbConfig);

		salaDao = DAOTstFactory.getSalaDAO(db);

		salaDao.removeSala(10);
		sala.setNumero("10");
		sala.setBloco("F");
		sala.setCampus("RJ");
	}

	@Test
	public void testAdicionarSala() {
		String msg = salaDao.adicionarSala(sala);
		assertTrue(msg.contains("Sala Cadastrada com Sucesso!"));
	}
}
