# HG changeset patch
# User juanjose.montesdeocaarbos
# Date 1317991315 10800
# Node ID bdc946dd5c9415652c0e2eba1cc9e200f5c16414
# Parent 31fb96912d37f2cd8a67012a670d7902e6e44cbf
Agregando Tests a Agenda.Web
diff -r 31fb96912d37 -r bdc946dd5c94 Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj
--- a/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Thu Oct 06 09:09:37 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Fri Oct 07 09:41:55 2011 -0300
@@ -46,6 +46,7 @@
+
diff -r 31fb96912d37 -r bdc946dd5c94 Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs
--- a/Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs Thu Oct 06 09:09:37 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs Fri Oct 07 09:41:55 2011 -0300
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Web.Mvc;
using Agendas.NHibernate;
using Agendas.Repositories.Tests.Infraestructure;
@@ -58,8 +57,60 @@
SetearUsuario();
}
+ [Test]
+ public void Nuevo_Evento()
+ {
+ ViewResult viewResult = null;
+ IEnumerable eventosDto = null;
+ EventoPublicarModel eventoPublicar = null;
+ var eventoController = new EventoController();
+
+ var eventoNew = new EventoNewModel
+ {
+ Duracion = new TimeSpan(0, 0, 0),
+ Fecha = DateTime.Today.AddDays(15),
+ Hora = new TimeSpan(18, 0, 0),
+ Ponentes = new[] { GetGuidPersona() },
+ TipoEvento = (int)TipoEvento.Van,
+ Titulo = "Título"
+ };
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = eventoController.Nuevo(eventoNew);
+ Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultNuevo);
+ Assert.AreEqual("Index", ((RedirectToRouteResult) resultNuevo).RouteValues["action"]);
+ }
+ }
+
+ [Test]
+ public void Nuevo_Evento_Erroneo_Sin_Ponente()
+ {
+ ViewResult viewResult = null;
+ IEnumerable eventosDto = null;
+ EventoPublicarModel eventoPublicar = null;
+ var eventoController = new EventoController();
+
+ var eventoNew = new EventoNewModel
+ {
+ Duracion = new TimeSpan(0, 0, 0),
+ Fecha = DateTime.Today.AddDays(15),
+ Hora = new TimeSpan(18, 0, 0),
+ TipoEvento = (int)TipoEvento.Van,
+ Titulo = "Título"
+ };
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = (ViewResult)eventoController.Nuevo(eventoNew);
+ var modelState = resultNuevo.ViewData.ModelState.FirstOrDefault().Value;
+ Assert.AreEqual(1, modelState.Errors.Count);
+ Assert.AreEqual("Debe indicar el ponente para este tipo de evento", modelState.Errors.FirstOrDefault().ErrorMessage);
+ }
+ }
+
[Test]
- public void Publicar_Evento()
+ public void Publicar_Evento_Erroneo_Duracion_Fuera_Rango()
{
ViewResult viewResult = null;
IEnumerable eventosDto = null;
@@ -111,6 +162,6 @@
}
}
- }
+ }
}
\ No newline at end of file