annotate Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrud.cs @ 109:6bd9be78caa0

Merge
author Nelo@Kenia.neluz.int
date Tue, 07 Jun 2011 23:21:07 -0300
parents 80c22175c9b5
children c3573defd18f
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 {
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
27 var ponente = new Persona("Carlos Blé");
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
106
80c22175c9b5 agregado de tipo de evento (van, cafe, grupoestudio)
jorge.rowies
parents: 97
diff changeset
30 var evento = Evento.Proponer("TDD - Diseño Basado en Ejemplos", ponente, string.Empty, TipoEvento.Van);
87
26d0513a8410 A los publicadores les llega la lista de tracks producidos en la acción realizada
nelopauselli
parents: 80
diff changeset
31 _eventoRepository.Save(evento);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
32
87
26d0513a8410 A los publicadores les llega la lista de tracks producidos en la acción realizada
nelopauselli
parents: 80
diff changeset
33 return evento.Id;
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
34 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
35 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
36
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
37 public void Read()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
38 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
39 Guid eventoId = Create();
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 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
42 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
43 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
44
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
45 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
46 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
47 Assert.AreEqual("Carlos Blé", van.Ponente.Nombre);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
48
80
c2d98fd6593f Track como objeto identificable y con referencia al evento correspondiente.
nelopauselli
parents: 79
diff changeset
49 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
50 Assert.IsNotNull(track1);
c2d98fd6593f Track como objeto identificable y con referencia al evento correspondiente.
nelopauselli
parents: 79
diff changeset
51 Assert.AreEqual(van, track1.Evento);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
52
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
53 Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
54 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
55 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
56
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
57 public void Update()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
58 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
59 Guid eventoId = Create();
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 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
62 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
63 Evento van = _eventoRepository.Get(eventoId);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
64
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
65 Assert.IsNotNull(van);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
66
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
67 van.CambiarTitulo("TDD & Ejemplos");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
68
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
69 var otroPonente = new Persona("José");
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
70 _personaRepository.Save(otroPonente);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
71
79
8df9db937434 Url de invitación en la UI: validación y persistencia
nelopauselli
parents: 75
diff changeset
72 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
73
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
74 _eventoRepository.Update(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
75 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
76
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
77 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
78 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
79 Evento van = _eventoRepository.Get(eventoId);
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 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
82 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
83 Assert.AreEqual("José", van.Ponente.Nombre);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
84 Assert.AreEqual("TDD & Ejemplos", van.Titulo);
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
85 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
86
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
87 var ponente1 = _personaRepository.GetByNombre("Carlos Blé");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
88 Assert.IsNotNull(ponente1);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
89
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
90 var ponente2 = _personaRepository.GetByNombre("José");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
91 Assert.IsNotNull(ponente2);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
92
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
93 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
94 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
95 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
96 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
97
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
98 public void Delete()
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
99 {
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
100 Guid eventoId = Create();
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 using (_requestEmulator.Invoke())
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
103 {
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
104 Evento van = _eventoRepository.Get(eventoId);
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
105 Assert.IsNotNull(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
106
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
107 _eventoRepository.Delete(van);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
108 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
109
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
110 using (_requestEmulator.Invoke())
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 Evento van = _eventoRepository.Get(eventoId);
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 Assert.IsNull(van);
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
115
94
db4b1e2cae49 Cambio del nombre de la clase Ponente a Persona
Nelo@Kenia.neluz.int
parents: 87
diff changeset
116 var ponente = _personaRepository.GetByNombre("Carlos Blé");
62
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
117
c40b97bbed01 Verificando persistencia de Ponentes y Tracks en tests de CRUD
nelopauselli
parents: 60
diff changeset
118 Assert.IsNotNull(ponente);
60
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
119 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
120 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
121 }
02e163f2ca38 Refactoring de test de crud del evento
nelopauselli
parents:
diff changeset
122 }