package test.br.com.kungfood.repository;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import br.com.kungFood.model.ComboModel;
import br.com.kungFood.repository.ComboRepository;


public class ComboRepositoryTest {

	ComboRepository dao;
	ComboModel comboModel;
	
	@Before
	public void setUP() throws Exception {
	
		dao = new ComboRepository();
		comboModel = new ComboModel();
		
		comboModel.setNm_combo("dd");
		comboModel.setDs_combo("dd");
		comboModel.setVl_combo(13.00);

	}
	
	@After
	public void tearDown() throws Exception {
		dao = null;
	}
	
	@Test
	public void testSalvarCombo() {
		
		dao.salvarNovoCombo(comboModel);
		List<ComboModel> combo = dao.getCombo();
		
			assertNotNull("T02", combo);
		
		int tamanho = combo.size();
		System.out.println("Tamanho: " + tamanho);
		
			assertTrue("T02", combo.contains(comboModel));

		dao.excluir(comboModel.getId_combo());
		assertEquals("t01", tamanho, combo.size());
				
		ComboModel cm = combo.get(0);
		
		assertEquals("t02", "asdw", cm.getDs_combo());
		assertEquals("t03", "uerli", cm.getNm_combo());
		assertEquals("t06", new Double(0.99), new Double(cm.getVl_combo()));
		
			dao.excluir(comboModel.getId_combo());
	}
	
	@Test
	public void testGetCombo() {
		dao.salvarNovoCombo(comboModel);
		
		List<ComboModel> combo = dao.getCombo();

		assertNotNull("T02", combo);

		int tamanho = combo.size();
		System.out.println("Tamanho: " + tamanho);

		// Inserir um Produto

		combo = dao.getCombo();

		assertEquals("T02", tamanho, combo.size());	
		dao.excluir(comboModel.getId_combo());
	}

	@Test
	public void testAlterar()  throws ParseException {
		dao.salvarNovoCombo(comboModel);
		
		dao.alterarRegistro(comboModel);
		
		List<ComboModel> combo = dao.getCombo();
		ComboModel cm = combo.get(0);
		assertNotSame("t03", combo.size(), comboModel.getId_combo());
//		assertEquals("T02", "asdw", cm.getDs_combo());
		
	}

	@Test
	public void testExcluir() {
		dao.salvarNovoCombo(comboModel);
		
		dao.excluir(comboModel.getId_combo());
		dao = null;
		
	}
	
}

@@ -176,51 +176,8 @@
 me;%0A
-import static org.junit.Assert.assertTrue;%0A
 impo
@@ -903,35 +903,35 @@
 %09assertNotNull(%22
-T02
+t01
 %22, combo);%0A%09%09%0A%09%09
@@ -1012,97 +1012,8 @@
 %09%0A%09%09
-%09assertTrue(%22T02%22, combo.contains(comboModel));%0A%0A%09%09dao.excluir(comboModel.getId_combo());
 %0A%09%09a
@@ -1027,17 +1027,17 @@
 uals(%22t0
-1
+2
 %22, taman
@@ -1058,17 +1058,16 @@
 ());%0A%09%09%09
-%09
 %0A%09%09Combo
@@ -1091,18 +1091,16 @@
 get(0);%0A
-%09%09
 %0A%09%09asser
@@ -1110,25 +1110,23 @@
 uals(%22t0
-2
+3
 %22, %22
-asdw
+dd
 %22, cm.ge
@@ -1161,18 +1161,15 @@
 (%22t0
-3
+4
 %22, %22
-uerli
+dd
 %22, c
@@ -1208,9 +1208,9 @@
 (%22t0
-6
+5
 %22, n
@@ -1223,12 +1223,13 @@
 ble(
-0.99
+13.00
 ), n
@@ -1927,25 +1927,17 @@
 ize(), c
-omboModel
+m
 .getId_c
@@ -1949,48 +1949,30 @@
 ));%0A
-//%09%09assertEquals(%22T02%22, %22asdw%22, 
+%09%09dao.excluir(
 cm.get
-Ds
+Id
 _com

teste de combo