package agilpizza.servlet;

import static org.junit.Assert.*;
import org.junit.Test;


public class ValidacaoUtilTest {

	@Test
	public void testIsVazio(){
		assertTrue("string vazia", ValidacaoUtil.isVazio(""));
		assertTrue("string com espaços", ValidacaoUtil.isVazio("    "));
		assertTrue("string nula", ValidacaoUtil.isVazio(null));
		assertFalse("string normal", ValidacaoUtil.isVazio("a"));
		assertFalse("string normal", ValidacaoUtil.isVazio("aasdfsad asdas  sadsad qw"));
	}
	
	@Test
	public void testIsNumero(){
		assertTrue("numero retorna verdadeiro", ValidacaoUtil.isNumero("100"));
		assertFalse("palavras nao sao numeros", ValidacaoUtil.isNumero("A"));
		assertFalse("string vazia", ValidacaoUtil.isNumero(""));
		assertTrue("numero decimal", ValidacaoUtil.isNumero("93.57"));
		assertTrue("numero negativo", ValidacaoUtil.isNumero("-93.57"));
	}
	@Test
	public void testIsTelefone() {
		assertTrue("555-1234", ValidacaoUtil.validaTelefone("555-1234"));
		assertTrue("5551234", ValidacaoUtil.validaTelefone("5551234"));
		assertTrue("5555-1234", ValidacaoUtil.validaTelefone("5555-1234"));
		assertTrue("55551234", ValidacaoUtil.validaTelefone("55551234"));
		
		assertFalse ("", ValidacaoUtil.validaTelefone(""));
		assertFalse ("555*1234", ValidacaoUtil.validaTelefone("555*1234"));
		assertFalse ("555-1-000", ValidacaoUtil.validaTelefone("555-1-000"));
		assertFalse ("555-1-0000", ValidacaoUtil.validaTelefone("555-1-0000"));
		assertFalse ("5555*1234", ValidacaoUtil.validaTelefone("5555*1234"));
		assertFalse ("55555-123", ValidacaoUtil.validaTelefone("55555-123"));
		assertFalse ("55-1234", ValidacaoUtil.validaTelefone("55-1234"));
		assertFalse ("555-12345", ValidacaoUtil.validaTelefone("555-12345"));
		assertFalse ("1234567890", ValidacaoUtil.validaTelefone("1234567890"));
		assertFalse("nulo não é telefone", ValidacaoUtil.validaTelefone(null));
		
	}
	
}
