annotate Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorControllerTests.cs @ 302:11dddcc9a862 tip

Historico de Eventos, no muestra bien la Url del Patrocinador.
author juanjose.montesdeocaarbos
date Tue, 14 Aug 2012 21:54:30 -0300
parents 48ab8788bd19
children
rev   line source
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
1 using System;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
2 using System.Collections.Generic;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
3 using System.IO;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
4 using System.Linq;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
5 using System.Text;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
6 using System.Web;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
7 using System.Web.Mvc;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
8 using System.Web.Routing;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
9 using Agendas.NHibernate;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
10 using Agendas.Repositories.Tests.Infraestructure;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
11 using Agendas.Web.Tests.Helpers;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
12 using AltNetHispano.Agendas.Repositories.NHibernate;
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
13 using AltNetHispano.Agendas.Web.Controllers;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
14 using AltNetHispano.Agendas.Web.Models;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
15 using Moq;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
16 using NUnit.Framework;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
17 using System.Drawing;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
18
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
19 namespace Agendas.Web.Tests.Controllers
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
20 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
21 [TestFixture]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
22 public class PatrocinadorControllerTests : MvcControllerTestsBase
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
23 {
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
24 internal void CrearPatrocinadorApress()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
25 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
26 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
27 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
28 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
29 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
30 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
31 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
32 {"Nombre", "APRESS"},
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
33 {"WebSite", "http://apress.com/"},
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
34 {"Logo", @"images\apress.gif"}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
35 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
36 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
37
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
38 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
39 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
40 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
41 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
42 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
43
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
44 internal void RegisterBinders()
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
45 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
46 ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
47 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
48
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
49 [SetUp]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
50 public void SetUpTests()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
51 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
52 NhHelperTest.CleanDb();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
53 RegisterBinders();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
54 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
55
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
56 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
57 public void PatrocinadorIndexGet()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
58 {
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
59 CrearPatrocinadorApress();
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
60
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
61 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
62 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
63 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
64 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
65 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
66 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
67 var resultIndex = patrocinadorController.Index();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
68 Assert.IsInstanceOf(typeof(ViewResult), resultIndex);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
69 Assert.AreEqual("", ((ViewResult)resultIndex).ViewName);
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
70
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
71 var model = (PatrocinadorIndexModel)((ViewResult) resultIndex).Model;
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
72 Assert.AreEqual(1, model.Items.Count());
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
73
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
74 Assert.AreEqual("APRESS", model.Items.FirstOrDefault().Nombre);
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
75 Assert.AreEqual("http://apress.com/", model.Items.FirstOrDefault().WebSite);
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
76 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
77 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
78
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
79 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
80 public void PatrocinadorNuevoGet()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
81 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
82 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
83 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
84 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
85 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
86 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
87 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
88 var resultNuevo = patrocinadorController.Nuevo();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
89 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
90 Assert.AreEqual("DefaultEditor", ((ViewResult)resultNuevo).ViewName); //UploadFileEditor
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
91 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
92 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
93
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
94 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
95 public void PatrocinadorNuevoPostSatisfactorio()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
96 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
97 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
98 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
99 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
100 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
101 var form = new FormCollection
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
102 {
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
103 {"Nombre", "APRESS"},
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
104 {"WebSite", "http://apress.com/"},
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
105 {"Logo", @"images\apress.gif"}
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
106 };
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
107 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
108
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
109 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
110 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
111 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
112 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
113 var viewResultNuevo = (RedirectToRouteResult)resultNuevo;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
114 Assert.AreEqual("Index", viewResultNuevo.RouteValues["action"]);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
115 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
116 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
117
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
118 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
119 public void PatrocinadorNuevoPostRequiredFields()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
120 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
121 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
122 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
123 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
124 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
125 var form = new FormCollection
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
126 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
127 {"Nombre", ""},
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
128 {"Logo", "" }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
129 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
130 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
131
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
132 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
133 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
134 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
135 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
136 var viewResultNuevo = (ViewResult)resultNuevo;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
137 Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName);
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
138 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
139 Assert.AreEqual("El campo Nombre es obligatorio.", viewResultNuevo.ViewData.ModelState["Nombre"].Errors[0].ErrorMessage);
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
140 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count);
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
141 Assert.AreEqual("El campo WebSite es obligatorio.", viewResultNuevo.ViewData.ModelState["WebSite"].Errors[0].ErrorMessage);
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
142 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
143 Assert.AreEqual("El campo Logo es obligatorio.", viewResultNuevo.ViewData.ModelState["Logo"].Errors[0].ErrorMessage);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
144 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
145 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
146
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
147 [Test]
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
148 public void PatrocinadorNuevoPostExists()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
149 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
150 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
151
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
152 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
153 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
154 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
155 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
156 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
157 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
158 {"Nombre", "APRESS"},
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
159 {"WebSite", "http://apress.com/"},
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
160 {"Logo", @"images\apress.gif"}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
161 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
162 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
163
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
164 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
165 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
166 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
167 Assert.IsInstanceOf(typeof (ViewResult), resultNuevo);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
168 var viewResultNuevo = (ViewResult) resultNuevo;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
169
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
170 Assert.AreEqual("El patrocinador ya existe.", viewResultNuevo.TempData["error"]);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
171 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
172 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
173
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
174 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
175 public void PatrocinadorModificarGetDontExists()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
176 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
177
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
178 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
179 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
180 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
181 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
182 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
183 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
184 var patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
185 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
186 var resultModificar = patrocinadorController.Modificar("11111111-1111-1111-1111-111111111111");
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
187 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
188 Assert.AreEqual("Index", ((RedirectToRouteResult)resultModificar).RouteValues["action"]);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
189 Assert.AreEqual("No se encontró el patrocinador que intenta modificar", patrocinadorController.TempData["error"]);
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
190 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
191 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
192 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
193
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
194 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
195 public void PatrocinadorModificarGetExists()
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
196 {
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
197 CrearPatrocinadorApress();
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
198
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
199 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
200 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
201 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
202 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
203
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
204 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
205 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
206 var patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
207 var resultModificar = patrocinadorController.Modificar(patrocinadorRepository.GetAll().FirstOrDefault().Id.ToString());
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
208 Assert.IsInstanceOf(typeof(ViewResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
209 Assert.AreEqual("DefaultEditor", ((ViewResult)resultModificar).ViewName);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
210 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
211 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
212
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
213 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
214 public void PatrocinadorModificarPostSatisfactorio()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
215 {
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
216 var Id = Guid.Empty;
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
217 PatrocinadorRepository patrocinadorRepository;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
218 PatrocinadorEditModel patrocinadorEdit;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
219
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
220 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
221 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
222 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
223 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
224 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
225 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
226 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
227 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
228 Id = patrocinadorRepository.GetAll().FirstOrDefault().Id;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
229 var form = new FormCollection
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
230 {
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
231 {"Id", Id.ToString()},
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
232 {"Nombre", "APRESS2"},
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
233 {"WebSite", "http://apress.com/2"},
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
234 {"Logo", @"images\apress.gif"}
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
235 };
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
236 patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
237 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
238
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
239 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
240 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
241 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
242 var resultModificar = patrocinadorController.Modificar(patrocinadorEdit);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
243 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
244 var viewResultEdit = (RedirectToRouteResult)resultModificar;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
245 Assert.AreEqual("Index", viewResultEdit.RouteValues["action"]);
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
246 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
247 }
300
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
248 using (new RequestEmulator(NhHelper.GetSessionFactory()))
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
249 {
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
250 var patrocinador = patrocinadorRepository.GetById(Id.ToString());
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
251
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
252 Assert.AreEqual("APRESS2", patrocinador.Nombre);
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
253 Assert.AreEqual("http://apress.com/2", patrocinador.WebSite);
48ab8788bd19 #200: Patrocinadores: Agregar link al sitio web.
juanjose.montesdeocaarbos
parents: 279
diff changeset
254 }
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
255 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
256
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
257 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
258 public void PatrocinadorModificarPostRequiredFields()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
259 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
260 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
261 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
262 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
263 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
264 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
265 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
266 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
267 {"Id", ""},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
268 {"Nombre", ""},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
269 {"Logo", ""}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
270 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
271 var patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
272
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
273 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
274 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
275 var resultModificar = patrocinadorController.Modificar(patrocinadorEdit);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
276 Assert.IsInstanceOf(typeof(ViewResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
277 var viewResultNuevo = (ViewResult)resultModificar;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
278 Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
279 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
280 Assert.AreEqual("El campo Nombre es obligatorio.", viewResultNuevo.ViewData.ModelState["Nombre"].Errors[0].ErrorMessage);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
281 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
282 Assert.AreEqual("El campo Logo es obligatorio.", viewResultNuevo.ViewData.ModelState["Logo"].Errors[0].ErrorMessage);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
283 }
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
284 }
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
285
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
286 [Test]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
287 public void PatrocinadorQuitarPostSatisfactorio()
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
288 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
289 var patrocinadorId = string.Empty;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
290 PatrocinadorRepository patrocinadorRepository;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
291
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
292 CrearPatrocinadorApress();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
293 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
294 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
295 ControllerContext = ControllerCtx
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
296 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
297 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
298 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
299 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
300 patrocinadorId = patrocinadorRepository.GetByNombre("Apress").Id.ToString();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
301 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
302
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
303 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
304 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
305 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
306 var resultQuitar = patrocinadorController.Eliminar(patrocinadorId);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
307 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultQuitar);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
308 var viewResult = (RedirectToRouteResult)resultQuitar;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
309 Assert.AreEqual("Index", viewResult.RouteValues["action"]);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
310 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
311 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
312 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
313 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
314 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
315 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
316
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
317 [Test]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
318 [Ignore]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
319 public void PatrocinadorQuitarPostDontExists()
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
320 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
321 PatrocinadorRepository patrocinadorRepository;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
322 PatrocinadorEditModel patrocinadorEdit;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
323
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
324 CrearPatrocinadorApress();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
325 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
326 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
327 ControllerContext = ControllerCtx
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
328 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
329 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
330 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
331 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
332
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
333 var form = new FormCollection
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
334 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
335 {"Id", patrocinadorRepository.GetAll().FirstOrDefault().Id.ToString()},
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
336 {"Nombre", "APRESS"},
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
337 {"Logo", @"images\apress.gif"}
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
338 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
339 patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
340 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
341
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
342 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
343 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
344 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
345 var resultQuit = patrocinadorController.Modificar(patrocinadorEdit);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
346 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultQuit);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
347 var viewResult = (RedirectToRouteResult)resultQuit;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
348 Assert.AreEqual("Index", viewResult.RouteValues["action"]);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
349 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
350 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
351 }
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
352 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
353 }