Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorControllerTests.cs @ 275:bf993f99cee3
Ticket #123: Patrocinadores de las vans.
author | juanjose.montesdeocaarbos |
---|---|
date | Wed, 14 Dec 2011 08:15:44 -0300 |
parents | |
children | 6f5ab71614d4 |
comparison
equal
deleted
inserted
replaced
274:72a96459f910 | 275:bf993f99cee3 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.IO; | |
4 using System.Linq; | |
5 using System.Text; | |
6 using System.Web; | |
7 using System.Web.Mvc; | |
8 using System.Web.Routing; | |
9 using Agendas.NHibernate; | |
10 using Agendas.Repositories.Tests.Infraestructure; | |
11 using Agendas.Web.Tests.Helpers; | |
12 using AltNetHispano.Agendas.Web.Controllers; | |
13 using AltNetHispano.Agendas.Web.Models; | |
14 using Moq; | |
15 using NUnit.Framework; | |
16 using System.Drawing; | |
17 | |
18 namespace Agendas.Web.Tests.Controllers | |
19 { | |
20 [TestFixture] | |
21 public class PatrocinadorControllerTests : MvcControllerTestsBase | |
22 { | |
23 [SetUp] | |
24 public void RegisterBinders() | |
25 { | |
26 ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder(); | |
27 } | |
28 | |
29 [Test] | |
30 public void PatrocinadorIndexGet() | |
31 { | |
32 var patrocinadorController = new PatrocinadorController(new HttpServerStub()) | |
33 { | |
34 ControllerContext = ControllerCtx | |
35 }; | |
36 using (new RequestEmulator(NhHelper.GetSessionFactory())) | |
37 { | |
38 var resultIndex = patrocinadorController.Index(); | |
39 Assert.IsInstanceOf(typeof(ViewResult), resultIndex); | |
40 Assert.AreEqual("", ((ViewResult)resultIndex).ViewName); | |
41 } | |
42 } | |
43 | |
44 [Test] | |
45 public void PatrocinadorNuevoGet() | |
46 { | |
47 var patrocinadorController = new PatrocinadorController(new HttpServerStub()) | |
48 { | |
49 ControllerContext = ControllerCtx | |
50 }; | |
51 using (new RequestEmulator(NhHelper.GetSessionFactory())) | |
52 { | |
53 var resultNuevo = patrocinadorController.Nuevo(); | |
54 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo); | |
55 Assert.AreEqual("DefaultEditor", ((ViewResult)resultNuevo).ViewName); //UploadFileEditor | |
56 } | |
57 } | |
58 | |
59 [Test] | |
60 public void PatrocinadorNuevoPostSatisfactorio() | |
61 { | |
62 var patrocinadorController = new PatrocinadorController(new HttpServerStub()) | |
63 { | |
64 ControllerContext = ControllerCtx | |
65 }; | |
66 var form = new FormCollection | |
67 { | |
68 {"Nombre", "APRESS"}, | |
69 {"Logo", @"images\apress.gif"} | |
70 }; | |
71 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form); | |
72 | |
73 using (new RequestEmulator(NhHelper.GetSessionFactory())) | |
74 { | |
75 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew); | |
76 Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultNuevo); | |
77 var viewResultNuevo = (RedirectToRouteResult)resultNuevo; | |
78 Assert.AreEqual("Index", viewResultNuevo.RouteValues["action"]); | |
79 } | |
80 } | |
81 | |
82 [Test] | |
83 public void PatrocinadorNuevoPostRequiredFields() | |
84 { | |
85 var patrocinadorController = new PatrocinadorController(new HttpServerStub()) | |
86 { | |
87 ControllerContext = ControllerCtx | |
88 }; | |
89 var form = new FormCollection | |
90 { | |
91 {"Nombre", ""}, | |
92 {"Logo", "" } | |
93 }; | |
94 var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form); | |
95 | |
96 using (new RequestEmulator(NhHelper.GetSessionFactory())) | |
97 { | |
98 var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew); | |
99 Assert.IsInstanceOf(typeof(ViewResult), resultNuevo); | |
100 var viewResultNuevo = (ViewResult)resultNuevo; | |
101 Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName); //UploadFileEditor | |
102 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count); | |
103 Assert.AreEqual("El campo Nombre es obligatorio.", viewResultNuevo.ViewData.ModelState["Nombre"].Errors[0].ErrorMessage); | |
104 Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count); | |
105 Assert.AreEqual("El campo Logo es obligatorio.", viewResultNuevo.ViewData.ModelState["Logo"].Errors[0].ErrorMessage); | |
106 } | |
107 } | |
108 | |
109 [Test] | |
110 [Ignore] | |
111 public void PatrocinadorNuevoPostExistente() | |
112 { | |
113 | |
114 } | |
115 } | |
116 | |
117 } |