diff Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs @ 245:bdc946dd5c94

Agregando Tests a Agenda.Web
author juanjose.montesdeocaarbos
date Fri, 07 Oct 2011 09:41:55 -0300
parents 59f8fa2f835e
children cef4fc893333
line wrap: on
line diff
--- 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<EventoDto> 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<EventoDto> 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<EventoDto> eventosDto = null;
@@ -111,6 +162,6 @@
                 
             }
         }
-    }
+	}
 
 }
\ No newline at end of file