annotate Agendas/trunk/src/Agendas.Tests/PropuestasTests.cs @ 79:8df9db937434

Url de invitación en la UI: validación y persistencia
author nelopauselli
date Tue, 24 May 2011 18:08:59 -0300
parents 96d7609f2e08
children c76661cff260
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 AltNetHispano.Agendas.Domain;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
5 using AltNetHispano.Agendas.Domain.Exceptions;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
6 using AltNetHispano.Agendas.Domain.Repositories;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
7 using Moq;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
8 using NUnit.Framework;
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
9
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
10 namespace AltNetHispano.Agendas.Tests
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
11 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
12 [TestFixture]
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
13 public class PropuestasTests : TestBase
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
14 {
70
c7264bfc4b71 agregado de properties en clase Evento (UrlInvitacion, UrlWiki, NumeroOrden)
jorge.rowies
parents: 54
diff changeset
15 private const string urlInvitacion = "http://groups.google.com/group/altnet-hispano/browse_thread/thread/65d6d26eb381386e";
c7264bfc4b71 agregado de properties en clase Evento (UrlInvitacion, UrlWiki, NumeroOrden)
jorge.rowies
parents: 54
diff changeset
16
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
17 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
18 public void Crear_modificar_y_publicar_evento_propuesto()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
19 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
20 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
21
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
22 agenda.Proponer("Van", null, urlInvitacion);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
23 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
24 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
25 IList<Evento> eventosPublicados = agenda.GetEventosAgendados();
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
26
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
27 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
28 Assert.AreEqual(0, eventosPublicados.Count);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
29
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
30 var evento = eventosPropuestos.FirstOrDefault();
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
31 agenda.ModificarPropuesta(evento.Id, "Van 2", "otro ponente", urlInvitacion);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
32
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
33 eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
34 Assert.AreEqual(1, eventosPropuestos.Count);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
35
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
36 evento = eventosPropuestos.FirstOrDefault();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
37 Assert.AreEqual("Van 2", evento.Titulo);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
38 Assert.AreEqual("otro ponente", evento.Ponente.Nombre);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
39 }
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
40
74
bc46e7426c80 Refactoring de acciones según la definición del diagrama de estados en assembla
nelopauselli
parents: 70
diff changeset
41 var r = agenda.Agendar("Van 2", "jjmontes", DateTime.Now, urlInvitacion);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
42 Assert.IsTrue(r.Succeful);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
43 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
44 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
45 IList<Evento> eventosPublicados = agenda.GetEventosAgendados();
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
46
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
47 Assert.AreEqual(0, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
48 Assert.AreEqual(1, eventosPublicados.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
49 }
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
50 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
51
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
52 [Test]
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
53 public void Intentar_agendar_evento_propuesto_sin_indicar_fecha()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
54 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
55 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
56
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
57 {
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
58 agenda.Proponer("Van propuesta", null, urlInvitacion);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
59 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
60
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
61 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
62 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
63 Assert.IsNotNull(van);
74
bc46e7426c80 Refactoring de acciones según la definición del diagrama de estados en assembla
nelopauselli
parents: 70
diff changeset
64 var r = agenda.Agendar(van.Titulo, "Ponente", null,
70
c7264bfc4b71 agregado de properties en clase Evento (UrlInvitacion, UrlWiki, NumeroOrden)
jorge.rowies
parents: 54
diff changeset
65 urlInvitacion);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
66 Assert.IsFalse(r.Succeful);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
67 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
68 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
69
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
70 [Test]
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
71 public void Intentar_agendar_evento_propuesto_sin_indicar_ponente()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
72 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
73 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
74
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
75 {
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
76 agenda.Proponer("Van propuesta", null, urlInvitacion);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
77 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
78
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
79 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
80 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
81 Assert.IsNotNull(van);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
82
79
8df9db937434 Url de invitación en la UI: validación y persistencia
nelopauselli
parents: 75
diff changeset
83 van.Actualizar(null, DateTime.Today.AddDays(5), urlInvitacion);
74
bc46e7426c80 Refactoring de acciones según la definición del diagrama de estados en assembla
nelopauselli
parents: 70
diff changeset
84 var r = agenda.Agendar(van.Titulo, string.Empty, van.Fecha,
70
c7264bfc4b71 agregado de properties en clase Evento (UrlInvitacion, UrlWiki, NumeroOrden)
jorge.rowies
parents: 54
diff changeset
85 urlInvitacion);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
86 Assert.IsFalse(r.Succeful);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
87 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
88 }
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
89
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
90 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
91 public void Intentar_obtener_un_evento_inexistente()
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
92 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
93 var idEventoNoExistente = new Guid("99999999999999999999999999999999");
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
94
50
3ebe89c88caa Agregando propiedad al Evento sobre el Usuario que lo crea o que realizó la
nelopauselli
parents: 45
diff changeset
95 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
96
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
97 Assert.IsNull(agenda.GetEvento(idEventoNoExistente));
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
98 }
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
99
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
100 [Test]
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
101 public void Intentar_proponer_evento_sin_titulo()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
102 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
103 var repository = new Mock<IEventoRepository>();
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
104
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
105 var agenda = new Agenda(null, null, repository.Object, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
106
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
107 var r = agenda.Proponer(string.Empty, null, urlInvitacion);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
108 Assert.IsFalse(r.Succeful);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
109
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
110 repository.Verify(p => p.Save(It.IsAny<Evento>()), Times.Exactly(0));
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
111 }
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
112
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
113 [Test]
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
114 public void Intentar_proponer_evento_sin_usuario_autenticado()
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
115 {
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
116 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
117
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
118 SetCurrentUser(null);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
119
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
120 Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Proponer("Inmortalidad de la meduza.", null, urlInvitacion));
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
121 }
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
122
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
123 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
124 public void Proponer_evento_correctamente()
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
125 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
126 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
127 agenda.Proponer("Van propuesta", null, urlInvitacion);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
128
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
129 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
130 Assert.IsNotNull(eventosPropuestos);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
131 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
132 Assert.AreEqual("Van propuesta", eventosPropuestos[0].Titulo);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
133 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
134
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
135 [Test]
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
136 public void Verificar_propuesta_separada_de_publicacion()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
137 {
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
138 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
139
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
140 agenda.Proponer("Van propuesta", null, urlInvitacion);
74
bc46e7426c80 Refactoring de acciones según la definición del diagrama de estados en assembla
nelopauselli
parents: 70
diff changeset
141 var r = agenda.Agendar("Van publicada", "jjmontes", DateTime.Now,
70
c7264bfc4b71 agregado de properties en clase Evento (UrlInvitacion, UrlWiki, NumeroOrden)
jorge.rowies
parents: 54
diff changeset
142 urlInvitacion);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
143 Assert.IsTrue(r.Succeful);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
144
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
145 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
75
96d7609f2e08 Agendar evento propuesto
nelopauselli
parents: 74
diff changeset
146 IList<Evento> eventosPublicados = agenda.GetEventosAgendados();
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
147
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
148 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
149 Assert.AreEqual(1, eventosPublicados.Count);
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
150 }
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
151 }
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
152 }