Forked from anonymous/Evento_Novo_Criado_Corretamente.cs
Created
April 14, 2011 04:18
-
-
Save danielsilva/918881 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class Evento_Novo_Criado_Corretamente | |
{ | |
Evento evento; | |
DateTime dataAtual, dataInicioEvento, dataFimEvento; | |
[TestFixtureSetUp] | |
public void Setup() | |
{ | |
string nome = "Teste Nome"; | |
string descricao = "Teste Descricao"; | |
dataInicioEvento = new DateTime(2011, 01, 01, 8, 0, 0); | |
dataFimEvento = new DateTime(20110, 01, 01, 10, 0, 0); | |
Grupo grupo = new Grupo("Teste Grupo"); | |
TipoEventoEnum tipoDoEvento = TipoEventoEnum.Comum; | |
dataAtual = DateTime.Now; | |
evento = new Evento(nome, descricao, dataInicioEvento, dataFimEvento, grupo, tipoDoEvento); | |
} | |
[Test] | |
public void Possui_DataCadastro_Igual_A_Data_Atual() | |
{ | |
Assert.AreEqual(dataAtual.ToString("dd/MM/yyyy hh:mm"), evento.DataCadastro.ToString("dd/MM/yyyy hh:mm")); | |
} | |
[Test] | |
public void Mapeia_Nome_Corretamente() | |
{ | |
Assert.AreEqual("Teste Nome", evento.Nome); | |
} | |
[Test] | |
public void Mapeia_Descricao_Corretamente() | |
{ | |
Assert.AreEqual("Teste Descricao", evento.Descricao); | |
} | |
[Test] | |
public void Mapeia_DataInicio_Corretamente() | |
{ | |
Assert.AreEqual(dataInicioEvento, evento.DataInicio); | |
} | |
[Test] | |
public void Mapeia_DataFim_Corretamente() | |
{ | |
Assert.AreEqual(dataFimEvento, evento.DataFim); | |
} | |
[Test] | |
public void Mapeia_Grupo_Corretamente() | |
{ | |
Assert.AreEqual(0, evento.Grupo.Id); | |
} | |
[Test] | |
public void Mapeia_TipoEvento_Corretamente() | |
{ | |
Assert.AreEqual(TipoEventoEnum.Comum, evento.Tipo); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class Evento_Novo_Validacoes | |
{ | |
string nome, descricao; | |
DateTime dataInicioEvento, dataFimEvento; | |
Grupo grupo; | |
TipoEventoEnum tipoDoEvento; | |
Evento evento; | |
[SetUp] | |
public void Setup() | |
{ | |
nome = "Teste Nome"; | |
descricao = "Teste Descricao"; | |
dataInicioEvento = new DateTime(2011, 01, 01, 8, 0, 0); | |
dataFimEvento = new DateTime(2011, 01, 01, 10, 0, 0); | |
grupo = new Grupo("Teste Grupo"); | |
tipoDoEvento = TipoEventoEnum.Comum; | |
} | |
[Test] | |
[ExpectedException(typeof(ValidationException))] | |
public void Dispara_Excecao_Quando_Nome_Eh_Nulo() | |
{ | |
nome = null; | |
evento = new Evento(nome, descricao, dataInicioEvento, dataFimEvento, grupo, tipoDoEvento); | |
} | |
[Test] | |
[ExpectedException(typeof(ValidationException))] | |
public void Dispara_Excecao_Quando_Nome_Eh_Vazio() | |
{ | |
nome = " "; | |
evento = new Evento(nome, descricao, dataInicioEvento, dataFimEvento, grupo, tipoDoEvento); | |
} | |
[Test] | |
[ExpectedException(typeof(ValidationException))] | |
public void Dispara_Excecao_Quando_Nome_Tem_Mais_De_50_Caracteres() | |
{ | |
var nomeMaiorQue50 = new StringBuilder(); | |
nomeMaiorQue50.Length = 51; | |
nome = nomeMaiorQue50.ToString(); | |
evento = new Evento(nome, descricao, dataInicioEvento, dataFimEvento, grupo, tipoDoEvento); | |
} | |
[Test] | |
[ExpectedException(typeof(ValidationException))] | |
public void Dispara_Excecao_Quando_Descricao_Tem_Mais_De_150_Caracteres() | |
{ | |
var descricaoMaiorQue150 = new StringBuilder(); | |
descricaoMaiorQue150.Length = 151; | |
descricao = descricaoMaiorQue150.ToString(); | |
evento = new Evento(nome, descricao, dataInicioEvento, dataFimEvento, grupo, tipoDoEvento); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment