# HG changeset patch
# User juanjose.montesdeocaarbos
# Date 1325353555 10800
# Node ID c8f378272407f2a45edb485b88ae85d640ea9dd3
# Parent 79942e03011838506b2a184439d1f0143b811172
#123: Patrocinadores de las vans.
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj
--- a/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Wed Dec 28 09:35:27 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Sat Dec 31 14:45:55 2011 -0300
@@ -103,6 +103,9 @@
Always
+
+ Always
+
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Tests/images/oralogo_bk200.gif
Binary file Agendas/trunk/src/Agendas.Tests/images/oralogo_bk200.gif has changed
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj
--- a/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Wed Dec 28 09:35:27 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Sat Dec 31 14:45:55 2011 -0300
@@ -45,9 +45,11 @@
..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll
+
+
@@ -60,6 +62,7 @@
+
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Web.Tests/AutorizationsTests.cs
--- a/Agendas/trunk/src/Agendas.Web.Tests/AutorizationsTests.cs Wed Dec 28 09:35:27 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web.Tests/AutorizationsTests.cs Sat Dec 31 14:45:55 2011 -0300
@@ -41,7 +41,7 @@
"HomeController.Index", "HomeController.About", "EventoController.Index", "AccountController.LogOn",
"AccountController.LogOff", "AccountController.TwitterLogOn", "HistoricoController.Index",
"PersonaController.Index", "ErrorController.NoAutorizado", "PersonaController.Ver",
- "PatrocinadorController.Index", "PatrocinadorController.GetLogo"
+ "PatrocinadorController.Index", "PatrocinadorController.GetLogo", "PatrocinadorApiController.Nuevo"
};
#region Asserts
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorApiControllerTests.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorApiControllerTests.cs Sat Dec 31 14:45:55 2011 -0300
@@ -0,0 +1,136 @@
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Agendas.NHibernate;
+using Agendas.Repositories.Tests.Infraestructure;
+using Agendas.Web.Tests.Helpers;
+using AltNetHispano.Agendas.Domain;
+using AltNetHispano.Agendas.Repositories.NHibernate;
+using AltNetHispano.Agendas.Web.Controllers;
+using AltNetHispano.Agendas.Web.Models;
+using Moq;
+using NUnit.Framework;
+
+namespace Agendas.Web.Tests.Controllers
+{
+ [TestFixture]
+ public class PatrocinadorApiControllerTests: MvcControllerTestsBase
+ {
+ internal void CrearPatrocinadorApress()
+ {
+ var patrocinadorController = new PatrocinadorController(new HttpServerStub())
+ {
+ ControllerContext = ControllerCtx
+ };
+ var form = new FormCollection
+ {
+ {"Nombre", "APRESS"},
+ {"Logo", @"images\apress.gif"}
+ };
+ var patrocinadorNew = BindModel(patrocinadorController, form);
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
+ }
+ }
+
+ internal void RegisterBinders()
+ {
+ ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();
+ }
+
+ [SetUp]
+ public void SetUpTests()
+ {
+ NhHelperTest.CleanDb();
+ RegisterBinders();
+ }
+
+ [Test]
+ public void PatrocinadorNuevoGetSusseful()
+ {
+ var patrocinadorController = new PatrocinadorApiController { ControllerContext = ControllerCtx };
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = patrocinadorController.Nuevo();
+ Assert.IsInstanceOf(typeof(PartialViewResult), resultNuevo);
+ Assert.AreEqual(string.Empty, ((PartialViewResult)resultNuevo).ViewName);
+ }
+ }
+
+ [Test]
+ public void PatrocinadorNuevoPostErrorRequeriedFields()
+ {
+ var patrocinadorApiController = new PatrocinadorApiController(new HttpServerStub())
+ {
+ ControllerContext = ControllerCtx
+ };
+ var form = new FormCollection
+ {
+ {"Nombre", ""},
+ {"Logo", "" }
+ };
+ var patrocinadorApiNew = BindModel(patrocinadorApiController, form);
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = patrocinadorApiController.Nuevo(patrocinadorApiNew);
+ Assert.IsInstanceOf(typeof(JsonResult), resultNuevo);
+ var resultadoJsonNuevo = (Resultado)resultNuevo.Data;
+ Assert.IsFalse(resultadoJsonNuevo.Succeful);
+ //Assert.AreEqual("El Nombre es obligatorio,El Logo es obligatorio", resultadoJsonNuevo.Message);
+ }
+ }
+
+ [Test]
+ public void PatrocinadorNuevoPostErrorPatrocinadorExists()
+ {
+ CrearPatrocinadorApress();
+
+ var patrocinadorApiController = new PatrocinadorApiController(new HttpServerStub())
+ {
+ ControllerContext = ControllerCtx
+ };
+ var form = new FormCollection
+ {
+ {"Nombre", "Apress"},
+ {"Logo", @"images\apress.gif" }
+ };
+ var patrocinadorApiNew = BindModel(patrocinadorApiController, form);
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = patrocinadorApiController.Nuevo(patrocinadorApiNew);
+ Assert.IsInstanceOf(typeof(JsonResult), resultNuevo);
+ var resultadoJsonNuevo = (Resultado)resultNuevo.Data;
+ Assert.IsFalse(resultadoJsonNuevo.Succeful);
+ Assert.AreEqual("El patrocinador ya existe.", resultadoJsonNuevo.Message);
+ }
+ }
+
+ [Test]
+ public void PatrocinadorNuevoPostSusseful()
+ {
+ var patrocinadorApiController = new PatrocinadorApiController(new HttpServerStub())
+ {
+ ControllerContext = ControllerCtx
+ };
+ var form = new FormCollection
+ {
+ {"Nombre", "Apress"},
+ {"Logo", @"images\apress.gif" }
+ };
+ var patrocinadorApiNew = BindModel(patrocinadorApiController, form);
+
+ using (new RequestEmulator(NhHelper.GetSessionFactory()))
+ {
+ var resultNuevo = patrocinadorApiController.Nuevo(patrocinadorApiNew);
+ Assert.IsInstanceOf(typeof(JsonResult), resultNuevo);
+ var resultadoJsonNuevo = (Resultado)resultNuevo.Data;
+ Assert.IsTrue(resultadoJsonNuevo.Succeful);
+ Assert.AreEqual(string.Empty, resultadoJsonNuevo.Message);
+ }
+ }
+ }
+}
diff -r 79942e030118 -r c8f378272407 Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj
--- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Wed Dec 28 09:35:27 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Sat Dec 31 14:45:55 2011 -0300
@@ -67,6 +67,7 @@
+
@@ -257,6 +258,12 @@
+
+
+
+
+
+
+
\ No newline at end of file