comparison Agendas/trunk/src/Agendas.Tests/PropuestasTests.cs @ 50:3ebe89c88caa

Agregando propiedad al Evento sobre el Usuario que lo crea o que realizó la última modificación.
author nelopauselli
date Fri, 13 May 2011 23:29:05 -0300
parents 2edc705aae0a
children 4a63a73e38e4
comparison
equal deleted inserted replaced
49:be7a9720fb96 50:3ebe89c88caa
13 public class PropuestasTests : TestBase 13 public class PropuestasTests : TestBase
14 { 14 {
15 [Test] 15 [Test]
16 public void Propuesta_de_van_con_usuario_autenticado() 16 public void Propuesta_de_van_con_usuario_autenticado()
17 { 17 {
18 var seguridad = new Mock<ISeguridad>(); 18 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
19 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
20
21 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
22 agenda.Proponer("Van propuesta", null); 19 agenda.Proponer("Van propuesta", null);
23 20
24 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos(); 21 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
25 Assert.IsNotNull(eventosPropuestos); 22 Assert.IsNotNull(eventosPropuestos);
26 Assert.AreEqual(1, eventosPropuestos.Count); 23 Assert.AreEqual(1, eventosPropuestos.Count);
28 } 25 }
29 26
30 [Test] 27 [Test]
31 public void Verificar_propuesta_separada_de_publicacion() 28 public void Verificar_propuesta_separada_de_publicacion()
32 { 29 {
33 var agenda = new Agenda(null, null, SeguridadServiceDefault, DefaultEventoRepository, DefaultPonenteRepository); 30 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
34 31
35 agenda.Proponer("Van propuesta", null); 32 agenda.Proponer("Van propuesta", null);
36 agenda.Publicar("Van publicada", "jjmontes", DateTime.Now); 33 agenda.Publicar("Van publicada", "jjmontes", DateTime.Now);
37 34
38 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos(); 35 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
45 [Test] 42 [Test]
46 public void Propuesta_de_van_sin_titulo() 43 public void Propuesta_de_van_sin_titulo()
47 { 44 {
48 var repository = new Mock<IEventoRepository>(); 45 var repository = new Mock<IEventoRepository>();
49 46
50 var seguridad = new Mock<ISeguridad>(); 47 var agenda = new Agenda(null, null, repository.Object, DefaultPonenteRepository);
51 var agenda = new Agenda(null, null, seguridad.Object, repository.Object, DefaultPonenteRepository);
52 48
53 Assert.Throws<ValidationException>(() => agenda.Proponer(string.Empty, null)); 49 Assert.Throws<ValidationException>(() => agenda.Proponer(string.Empty, null));
54 50
55 repository.Verify(p => p.Save(It.IsAny<Evento>()), Times.Exactly(0)); 51 repository.Verify(p => p.Save(It.IsAny<Evento>()), Times.Exactly(0));
56 } 52 }
57 53
58 [Test] 54 [Test]
59 public void Agendar_van_propuesta_sin_fecha() 55 public void Agendar_van_propuesta_sin_fecha()
60 { 56 {
61 var seguridad = new Mock<ISeguridad>(); 57 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
62 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
63 58
64 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
65
66 { 59 {
67 agenda.Proponer("Van propuesta", null); 60 agenda.Proponer("Van propuesta", null);
68 } 61 }
69 62
70 { 63 {
75 } 68 }
76 69
77 [Test] 70 [Test]
78 public void Agendar_van_propuesta_sin_ponente() 71 public void Agendar_van_propuesta_sin_ponente()
79 { 72 {
80 var seguridad = new Mock<ISeguridad>(); 73 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
81 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
82 74
83 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
84
85 { 75 {
86 agenda.Proponer("Van propuesta", null); 76 agenda.Proponer("Van propuesta", null);
87 } 77 }
88 78
89 { 79 {
96 } 86 }
97 87
98 [Test] 88 [Test]
99 public void Modificar_y_publicar_van_propuesta() 89 public void Modificar_y_publicar_van_propuesta()
100 { 90 {
101 var agenda = new Agenda(null, null, SeguridadServiceDefault, DefaultEventoRepository, DefaultPonenteRepository); 91 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
102 92
103 agenda.Proponer("Van", null); 93 agenda.Proponer("Van", null);
104 { 94 {
105 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos(); 95 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
106 IList<Evento> eventosPublicados = agenda.GetEventosPublicados(); 96 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
130 } 120 }
131 121
132 [Test] 122 [Test]
133 public void Propuesta_de_van_sin_autenticacion() 123 public void Propuesta_de_van_sin_autenticacion()
134 { 124 {
135 var seguridad = new Mock<ISeguridad>(); 125 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
136 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
137 126
138 seguridad.Setup(s => s.GetPrincipal()).Returns(SeguridadObjectMother.GetGenericPrincipalSinAutenticar()); 127 SetCurrentUser(null);
139 128
140 Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Proponer("Inmortalidad de la meduza.", null)); 129 Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Proponer("Inmortalidad de la meduza.", null));
141 } 130 }
142 131
143 [Test] 132 [Test]
144 public void Obtener_un_evento_inexistente() 133 public void Obtener_un_evento_inexistente()
145 { 134 {
146 var idEventoNoExistente = new Guid("99999999999999999999999999999999"); 135 var idEventoNoExistente = new Guid("99999999999999999999999999999999");
147 136
148 var seguridad = new Mock<ISeguridad>(); 137 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
149 var agenda = new Agenda(null, null, seguridad.Object, DefaultEventoRepository, DefaultPonenteRepository);
150
151 seguridad.Setup(s => s.GetPrincipal()).Returns(
152 SeguridadObjectMother.GetGenericPrincipalAutenticadoSinRoles());
153 138
154 Assert.IsNull(agenda.GetEvento(idEventoNoExistente)); 139 Assert.IsNull(agenda.GetEvento(idEventoNoExistente));
155 } 140 }
156 } 141 }
157 } 142 }