changeset 245:bdc946dd5c94

Agregando Tests a Agenda.Web
author juanjose.montesdeocaarbos
date Fri, 07 Oct 2011 09:41:55 -0300
parents 31fb96912d37
children 70c5cab59054 9e1e2435388e
files Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Agendas/trunk/src/Agendas.Web.Tests/Controllers/EventoControllerTests.cs
diffstat 2 files changed, 55 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Web" />
     <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
--- 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