annotate Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrud.cs @ 161:c1062de96845

Al publicar una agenda el nroOrden debe ser mayor a cero y urlWiki no vacio.
author juanjose.montesdeocaarbos
date Fri, 05 Aug 2011 21:54:43 -0300
parents 2dbb15f4510f
children 5c94b052d838
rev   line source
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
1 using System;
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
2 using System.Linq;
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
3 using AltNetHispano.Agendas.Domain;
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
4 using AltNetHispano.Agendas.Domain.Repositories;
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
5 using NUnit.Framework;
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
6
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
7 namespace AltNetHispano.Agendas.Tests.Cruds
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
8 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
9 public class EventoCrud
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
10 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
11 private readonly IEventoRepository _eventoRepository;
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
12 private readonly Func<IDisposable> _requestEmulator;
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
13 private readonly IPersonaRepository _personaRepository;
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
14
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
15 public EventoCrud(Func<IEventoRepository> createEventoRepository, Func<IPersonaRepository> createPonenteRepository, Func<IDisposable> requestEmulator)
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
16 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
17 _eventoRepository = createEventoRepository.Invoke();
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
18 _personaRepository = createPonenteRepository.Invoke();
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
19
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
20 _requestEmulator = requestEmulator;
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
21 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
22
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
23 public Guid Create()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
24 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
25 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
26 {
143
2dbb15f4510f Asociar Twitter a Persona existente
Nelo@Guinea.neluz.int
parents: 140
diff changeset
27 var ponente = new Persona("Carlos Blé") {Twitter = "carlosble"};
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
28 _personaRepository.Save(ponente);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
29
143
2dbb15f4510f Asociar Twitter a Persona existente
Nelo@Guinea.neluz.int
parents: 140
diff changeset
30 var usuario = new Persona("Nelo") {Twitter = "nelopauselli"};
120
c3573defd18f Agregado de Fecha, Usuario y Successful en TrackLog
Jorge@Jorge-PC
parents: 106
diff changeset
31 _personaRepository.Save(usuario);
c3573defd18f Agregado de Fecha, Usuario y Successful en TrackLog
Jorge@Jorge-PC
parents: 106
diff changeset
32
c3573defd18f Agregado de Fecha, Usuario y Successful en TrackLog
Jorge@Jorge-PC
parents: 106
diff changeset
33 var evento = Evento.Proponer("TDD - Diseño Basado en Ejemplos", ponente, string.Empty, TipoEvento.Van);
c3573defd18f Agregado de Fecha, Usuario y Successful en TrackLog
Jorge@Jorge-PC
parents: 106
diff changeset
34 evento.Tracks.First().LogAdd(new TrackLog(TrackLogPropietario.Twitter, "Mensaje", usuario, true));
c3573defd18f Agregado de Fecha, Usuario y Successful en TrackLog
Jorge@Jorge-PC
parents: 106
diff changeset
35
87
26d0513a8410 A los publicadores les llega la lista de tracks producidos en la acción realizada
nelopauselli
parents: 80
diff changeset
36 _eventoRepository.Save(evento);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
37
87
26d0513a8410 A los publicadores les llega la lista de tracks producidos en la acción realizada
nelopauselli
parents: 80
diff changeset
38 return evento.Id;
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
39 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
40 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
41
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
42 public void Read()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
43 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
44 Guid eventoId = Create();
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
45
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
46 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
47 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
48 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
49
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
50 Assert.IsNotNull(van);
97
2434c2323f3d En el evento, volvemos a llamar Ponente a la persona que está a cargo de la presentación
Nelo@Kenia.neluz.int
parents: 95
diff changeset
51 Assert.IsNotNull(van.Ponente);
2434c2323f3d En el evento, volvemos a llamar Ponente a la persona que está a cargo de la presentación
Nelo@Kenia.neluz.int
parents: 95
diff changeset
52 Assert.AreEqual("Carlos Blé", van.Ponente.Nombre);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
53
80
c2d98fd6593f Track como objeto identificable y con referencia al evento correspondiente.
nelopauselli
parents: 79
diff changeset
54 var track1 = van.Tracks.Where(t => t.Accion == Accion.Proponer).FirstOrDefault();
c2d98fd6593f Track como objeto identificable y con referencia al evento correspondiente.
nelopauselli
parents: 79
diff changeset
55 Assert.IsNotNull(track1);
c2d98fd6593f Track como objeto identificable y con referencia al evento correspondiente.
nelopauselli
parents: 79
diff changeset
56 Assert.AreEqual(van, track1.Evento);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
57
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
58 Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
59 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
60 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
61
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
62 public void Update()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
63 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
64 Guid eventoId = Create();
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
65
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
66 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
67 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
68 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
69
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
70 Assert.IsNotNull(van);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
71
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
72 van.CambiarTitulo("TDD & Ejemplos");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
73
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
74 var otroPonente = new Persona("José");
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
75 _personaRepository.Save(otroPonente);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
76
79
8df9db937434 Url de invitación en la UI: validación y persistencia
nelopauselli
parents: 75
diff changeset
77 van.Actualizar(otroPonente, new DateTime(2010, 04, 17), null);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
78
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
79 _eventoRepository.Update(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
80 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
81
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
82 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
83 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
84 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
85
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
86 Assert.IsNotNull(van);
97
2434c2323f3d En el evento, volvemos a llamar Ponente a la persona que está a cargo de la presentación
Nelo@Kenia.neluz.int
parents: 95
diff changeset
87 Assert.IsNotNull(van.Ponente);
2434c2323f3d En el evento, volvemos a llamar Ponente a la persona que está a cargo de la presentación
Nelo@Kenia.neluz.int
parents: 95
diff changeset
88 Assert.AreEqual("José", van.Ponente.Nombre);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
89 Assert.AreEqual("TDD & Ejemplos", van.Titulo);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
90 Assert.AreEqual(new DateTime(2010, 04, 17), van.Fecha);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
91
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
92 var ponente1 = _personaRepository.GetByNombre("Carlos Blé");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
93 Assert.IsNotNull(ponente1);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
94
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
95 var ponente2 = _personaRepository.GetByNombre("José");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
96 Assert.IsNotNull(ponente2);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
97
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
98 Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Proponer).Count());
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
99 Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Modificar).Count());
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
100 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
101 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
102
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
103 public void Delete()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
104 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
105 Guid eventoId = Create();
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
106
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
107 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
108 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
109 Evento van = _eventoRepository.Get(eventoId);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
110 Assert.IsNotNull(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
111
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
112 _eventoRepository.Delete(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
113 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
114
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
115 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
116 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
117 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
118
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
119 Assert.IsNull(van);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
120
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
121 var ponente = _personaRepository.GetByNombre("Carlos Blé");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
122
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
123 Assert.IsNotNull(ponente);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
124 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
125 }
140
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
126
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
127 public void Workflow()
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
128 {
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
129 Guid eventoId = Create();
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
130
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
131 using (_requestEmulator.Invoke())
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
132 {
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
133 Evento evento = _eventoRepository.Get(eventoId);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
134 Assert.AreEqual(EventoPropuestoState.GetInstance(), evento.Estado);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
135
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
136 evento.Agendar(evento.Ponente, evento.Fecha, null);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
137 }
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
138
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
139 using (_requestEmulator.Invoke())
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
140 {
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
141 Evento evento = _eventoRepository.Get(eventoId);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
142 Assert.AreEqual(EventoAgendadoState.GetInstance(), evento.Estado);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
143
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
144 evento.Confirmar();
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
145 }
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
146
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
147 using (_requestEmulator.Invoke())
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
148 {
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
149 Evento evento = _eventoRepository.Get(eventoId);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
150 Assert.AreEqual(EventoConfirmadoState.GetInstance(), evento.Estado);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
151
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
152 evento.Publicar(1, null);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
153 }
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
154
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
155 using (_requestEmulator.Invoke())
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
156 {
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
157 Evento evento = _eventoRepository.Get(eventoId);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
158 Assert.AreEqual(EventoPublicadoState.GetInstance(), evento.Estado);
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
159 }
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 120
diff changeset
160 }
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
161 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
162 }