annotate Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorControllerTests.cs @ 283:2e17dfd1ba35

Cambiandos espacios por tabuladores, etc.
author juanjose.montesdeocaarbos
date Mon, 26 Dec 2011 14:34:46 -0300
parents 1e889a2e45c5
children 48ab8788bd19
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"},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
33 {"Logo", @"images\apress.gif"}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
34 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
35 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
36
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
37 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
38 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
39 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
40 }
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 internal void RegisterBinders()
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
44 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
45 ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
46 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
47
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
48 [SetUp]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
49 public void SetUpTests()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
50 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
51 NhHelperTest.CleanDb();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
52 RegisterBinders();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
53 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
54
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
55 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
56 public void PatrocinadorIndexGet()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
57 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
58 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
59 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
60 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
61 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
62 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
63 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
64 var resultIndex = patrocinadorController.Index();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
65 Assert.IsInstanceOf(typeof(ViewResult), resultIndex);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
66 Assert.AreEqual("", ((ViewResult)resultIndex).ViewName);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
67 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
68 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
69
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
70 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
71 public void PatrocinadorNuevoGet()
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
72 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
73 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
74 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
75 ControllerContext = ControllerCtx
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 using (new RequestEmulator(NhHelper.GetSessionFactory()))
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 var resultNuevo = patrocinadorController.Nuevo();
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
80 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
81 Assert.AreEqual("DefaultEditor", ((ViewResult)resultNuevo).ViewName); //UploadFileEditor
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
82 }
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
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
85 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
86 public void PatrocinadorNuevoPostSatisfactorio()
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 patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
89 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
90 ControllerContext = ControllerCtx
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 var form = new FormCollection
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 {"Nombre", "APRESS"},
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
95 {"Logo", @"images\apress.gif"}
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 patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
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 using (new RequestEmulator(NhHelper.GetSessionFactory()))
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 resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
102 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
103 var viewResultNuevo = (RedirectToRouteResult)resultNuevo;
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
104 Assert.AreEqual("Index", viewResultNuevo.RouteValues["action"]);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
105 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
106 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
107
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
108 [Test]
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
109 public void PatrocinadorNuevoPostRequiredFields()
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 patrocinadorController = new PatrocinadorController(new HttpServerStub())
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
112 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
113 ControllerContext = ControllerCtx
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
114 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
115 var form = new FormCollection
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 {"Nombre", ""},
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
118 {"Logo", "" }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
119 };
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
120 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
121
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
122 using (new RequestEmulator(NhHelper.GetSessionFactory()))
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
123 {
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
124 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
125 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
126 var viewResultNuevo = (ViewResult)resultNuevo;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
127 Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName);
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
128 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
129 Assert.AreEqual("El campo Nombre es obligatorio.", viewResultNuevo.ViewData.ModelState["Nombre"].Errors[0].ErrorMessage);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
130 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count);
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
131 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
132 }
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
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
135 [Test]
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
136 public void PatrocinadorNuevoPostExists()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
137 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
138 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
139
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
140 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
141 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
142 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
143 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
144 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
145 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
146 {"Nombre", "APRESS"},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
147 {"Logo", @"images\apress.gif"}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
148 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
149 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
150
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
151 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
152 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
153 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
154 Assert.IsInstanceOf(typeof (ViewResult), resultNuevo);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
155 var viewResultNuevo = (ViewResult) resultNuevo;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
156
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
157 Assert.AreEqual("El patrocinador ya existe.", viewResultNuevo.TempData["error"]);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
158 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
159 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
160
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
161 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
162 public void PatrocinadorModificarGetDontExists()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
163 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
164
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
165 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
166 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
167 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
168 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
169 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
170 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
171 var patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
172 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
173 var resultModificar = patrocinadorController.Modificar("11111111-1111-1111-1111-111111111111");
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
174 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
175 Assert.AreEqual("Index", ((RedirectToRouteResult)resultModificar).RouteValues["action"]);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
176 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
177 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
178 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
179 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
180
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
181 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
182 public void PatrocinadorModificarGetExists()
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
183 {
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
184 CrearPatrocinadorApress();
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
185
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
186 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
187 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
188 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
189 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
190
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
191 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
192 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
193 var patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
194 var resultModificar = patrocinadorController.Modificar(patrocinadorRepository.GetAll().FirstOrDefault().Id.ToString());
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
195 Assert.IsInstanceOf(typeof(ViewResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
196 Assert.AreEqual("DefaultEditor", ((ViewResult)resultModificar).ViewName);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
197 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
198 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
199
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
200 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
201 public void PatrocinadorModificarPostSatisfactorio()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
202 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
203 PatrocinadorRepository patrocinadorRepository;
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
204 PatrocinadorEditModel patrocinadorEdit;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
205
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
206 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
207 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
208 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
209 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
210 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
211 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
212 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
213 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
214
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
215 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
216 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
217 {"Id", patrocinadorRepository.GetAll().FirstOrDefault().Id.ToString()},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
218 {"Nombre", "APRESS"},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
219 {"Logo", @"images\apress.gif"}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
220 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
221 patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
222 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
223
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
224 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
225 {
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
226 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
227 var resultModificar = patrocinadorController.Modificar(patrocinadorEdit);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
228 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
229 var viewResultEdit = (RedirectToRouteResult)resultModificar;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
230 Assert.AreEqual("Index", viewResultEdit.RouteValues["action"]);
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
231 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
278
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
232 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
233 }
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
234
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
235 [Test]
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
236 public void PatrocinadorModificarPostRequiredFields()
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
237 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
238 CrearPatrocinadorApress();
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
239 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
240 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
241 ControllerContext = ControllerCtx
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
242 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
243 var form = new FormCollection
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
244 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
245 {"Id", ""},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
246 {"Nombre", ""},
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
247 {"Logo", ""}
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
248 };
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
249 var patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
250
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
251 using (new RequestEmulator(NhHelper.GetSessionFactory()))
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
252 {
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
253 var resultModificar = patrocinadorController.Modificar(patrocinadorEdit);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
254 Assert.IsInstanceOf(typeof(ViewResult), resultModificar);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
255 var viewResultNuevo = (ViewResult)resultModificar;
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
256 Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
257 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
258 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
259 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count);
6f5ab71614d4 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 275
diff changeset
260 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
261 }
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
262 }
279
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
263
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
264 [Test]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
265 public void PatrocinadorQuitarPostSatisfactorio()
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
266 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
267 var patrocinadorId = string.Empty;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
268 PatrocinadorRepository patrocinadorRepository;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
269
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
270 CrearPatrocinadorApress();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
271 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
272 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
273 ControllerContext = ControllerCtx
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
274 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
275 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
276 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
277 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
278 patrocinadorId = patrocinadorRepository.GetByNombre("Apress").Id.ToString();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
279 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
280
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
281 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
282 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
283 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
284 var resultQuitar = patrocinadorController.Eliminar(patrocinadorId);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
285 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultQuitar);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
286 var viewResult = (RedirectToRouteResult)resultQuitar;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
287 Assert.AreEqual("Index", viewResult.RouteValues["action"]);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
288 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
289 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
290 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
291 Assert.AreEqual(0, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
292 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
293 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
294
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
295 [Test]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
296 [Ignore]
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
297 public void PatrocinadorQuitarPostDontExists()
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 patrocinadorRepository;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
300 PatrocinadorEditModel patrocinadorEdit;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
301
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
302 CrearPatrocinadorApress();
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
303 var patrocinadorController = new PatrocinadorController(new HttpServerStub())
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
304 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
305 ControllerContext = ControllerCtx
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
306 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
307 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
308 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
309 patrocinadorRepository = new PatrocinadorRepository(NhHelper.GetSessionFactory());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
310
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
311 var form = new FormCollection
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
312 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
313 {"Id", patrocinadorRepository.GetAll().FirstOrDefault().Id.ToString()},
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
314 {"Nombre", "APRESS"},
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
315 {"Logo", @"images\apress.gif"}
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
316 };
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
317 patrocinadorEdit = BindModel<PatrocinadorEditModel>(patrocinadorController, form);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
318 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
319
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
320 using (new RequestEmulator(NhHelper.GetSessionFactory()))
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
321 {
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
322 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
323 var resultQuit = patrocinadorController.Modificar(patrocinadorEdit);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
324 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultQuit);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
325 var viewResult = (RedirectToRouteResult)resultQuit;
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
326 Assert.AreEqual("Index", viewResult.RouteValues["action"]);
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
327 Assert.AreEqual(1, patrocinadorRepository.GetAll().Count());
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
328 }
1e889a2e45c5 #125: ABM de patrocinadores.
juanjose.montesdeocaarbos
parents: 278
diff changeset
329 }
275
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
330 }
bf993f99cee3 Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
diff changeset
331 }