annotate Agendas/trunk/src/Agendas.Tests/PropuestasTests.cs @ 21:43360bf09b1a

unificando criterio de parámetros en Agenda
author nelo@MTEySS.neluz.int
date Mon, 14 Mar 2011 21:05:19 -0300
parents c5a99dde072f
children d6e124e5c9c4
rev   line source
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
1 using System;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
2 using System.Collections.Generic;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
3 using System.Linq;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
4 using Agendas.Repositories.Memory;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
5 using AltNetHispano.Agendas.Domain;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
6 using AltNetHispano.Agendas.Domain.Exceptions;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
7 using AltNetHispano.Agendas.Domain.Repositories;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
8 using Moq;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
9 using NUnit.Framework;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
10
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
11 namespace AltNetHispano.Agendas.Tests
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
12 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
13 [TestFixture]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
14 public class PropuestasTests : TestBase
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
15 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
16 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
17 public void Propuesta_de_van_con_usuario_autenticado()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
18 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
19 var repository = new EventoRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
21 var seguridad = new Mock<ISeguridad>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
22 var agenda = new Agenda(null, null, seguridad.Object, repository);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
23
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
24 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
25 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
26
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
27 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
28 Assert.IsNotNull(eventosPropuestos);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
29 Assert.AreEqual(1, eventosPropuestos.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
30 Assert.AreEqual("Van propuesta", eventosPropuestos[0].Titulo);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
31 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
32
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
33 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
34 public void Verificar_propuesta_separada_de_publicacion()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
35 {
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
36 var agenda = new Agenda(null, null, SeguridadServiceDefault, new EventoRepository());
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
37
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
38 var vanPublicada = EventoObjectMother.GetVanValidaParaPublicar();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
39
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
40 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
41 agenda.Publicar(vanPublicada.Titulo, vanPublicada.Ponente, vanPublicada.Fecha);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
42
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
43 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
44 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
45
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
46 Assert.AreEqual(1, eventosPropuestos.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
47 Assert.AreEqual(1, eventosPublicados.Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
48 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
49
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
50 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
51 public void Propuesta_de_van_sin_titulo()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
52 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
53 var repository = new Mock<IEventoRepository>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
54
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
55 var seguridad = new Mock<ISeguridad>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
56 var agenda = new Agenda(null, null, seguridad.Object, repository.Object);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
57
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
58 Assert.Throws<ValidationException>(() => agenda.Proponer(string.Empty));
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
59
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
60 repository.Verify(p => p.Save(It.IsAny<Evento>()), Times.Exactly(0));
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
61 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
62
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
63 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
64 public void Agendar_van_propuesta_sin_fecha()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
65 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
66 var repository = new EventoRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
67
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
68 var seguridad = new Mock<ISeguridad>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
69 var agenda = new Agenda(null, null, seguridad.Object, repository);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
70
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
71 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
72
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
73 {
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
74 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
75 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
76
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
77 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
78 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
79 Assert.IsNotNull(van);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
80 Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
81 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
82 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
83
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
84 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
85 public void Agendar_van_propuesta_sin_ponente()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
86 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
87 var repository = new EventoRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
88
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
89 var seguridad = new Mock<ISeguridad>();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
90 var agenda = new Agenda(null, null, seguridad.Object, repository);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
91
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
92 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
93
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
94 {
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 20
diff changeset
95 agenda.Proponer("Van propuesta");
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
96 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
97
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
98 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
99 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
100 Assert.IsNotNull(van);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
101
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
102 van.Fecha = DateTime.Today.AddDays(5);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
103 Assert.Throws<ValidationException>(() => agenda.Publicar(van.Titulo, van.Ponente, van.Fecha));
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
104 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
105 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
106
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
107 [Test]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
108 public void Van_crud()
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
109 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
110 var van = EventoObjectMother.GetVanValidaParaPublicar();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
111
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
112 Guid vanId;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
113 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
114 var agenda = new Agenda(null, null, SeguridadServiceDefault, new EventoRepository());
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
115 agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
116
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
117 IAgendaRepository agendaRepository = new AgendaRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
118
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
119 agendaRepository.Save(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
120 vanId = agenda.Id;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
121 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
122
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
123 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
124 IAgendaRepository agendaRepository = new AgendaRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
125
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
126 Agenda agenda = agendaRepository.Get(vanId);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
127
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
128 Assert.IsNotNull(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
129 Assert.AreEqual(1, agenda.GetEventosPublicados().Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
130 agenda.Publicar(van.Titulo, van.Ponente, van.Fecha);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
131
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
132 agendaRepository.Update(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
133 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
134
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
135 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
136 IAgendaRepository agendaRepository = new AgendaRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
137
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
138 Agenda agenda = agendaRepository.Get(vanId);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
139
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
140 Assert.IsNotNull(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
141 Assert.AreEqual(2, agenda.GetEventosPublicados().Count);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
142
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
143 agendaRepository.Delete(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
144 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
145
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
146 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
147 IAgendaRepository agendaRepository = new AgendaRepository();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
148
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
149 Agenda agenda = agendaRepository.Get(vanId);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
150
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
151 Assert.IsNull(agenda);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
152 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
153 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
154 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
155 }