annotate Agendas/trunk/src/Agendas.Tests/PropuestasTests.cs @ 68:99a7df8e35bd

Merge
author nelopauselli
date Thu, 19 May 2011 01:29:52 -0300
parents 3059a5f8930f
children c7264bfc4b71
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 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
15 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
16 public void Crear_modificar_y_publicar_evento_propuesto()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
17 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
18 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
19
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
20 agenda.Proponer("Van", null);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
21 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
22 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
23 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
24
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
25 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
26 Assert.AreEqual(0, eventosPublicados.Count);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
27
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
28 var evento = eventosPropuestos.FirstOrDefault();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
29 agenda.ModificarPropuesta(evento.Id, "Van 2", "otro ponente");
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
30
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
31 eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
32 Assert.AreEqual(1, eventosPropuestos.Count);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
33
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
34 evento = eventosPropuestos.FirstOrDefault();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
35 Assert.AreEqual("Van 2", evento.Titulo);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
36 Assert.AreEqual("otro ponente", evento.Ponente.Nombre);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
37 }
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
38
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
39 var r = agenda.Publicar("Van 2", "jjmontes", DateTime.Now);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
40 Assert.IsTrue(r.Succeful);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
41 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
42 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
43 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
44
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
45 Assert.AreEqual(0, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
46 Assert.AreEqual(1, eventosPublicados.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
47 }
20
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]
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
51 public void Intentar_agendar_evento_propuesto_sin_indicar_fecha()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
52 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
53 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
54
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
55 {
26
71b02443450a UI de Propuestas de VANs
nelo@MTEySS.neluz.int
parents: 24
diff changeset
56 agenda.Proponer("Van propuesta", null);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
57 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
58
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
59 {
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
60 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
61 Assert.IsNotNull(van);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
62 var r = agenda.Publicar(van.Titulo, "Ponente", null);
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
63 Assert.IsFalse(r.Succeful);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
64 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
65 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
66
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
67 [Test]
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
68 public void Intentar_agendar_evento_propuesto_sin_indicar_ponente()
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
69 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
70 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
71
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
72 {
26
71b02443450a UI de Propuestas de VANs
nelo@MTEySS.neluz.int
parents: 24
diff changeset
73 agenda.Proponer("Van propuesta", null);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
74 }
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 var van = agenda.GetEventosPropuestos().FirstOrDefault();
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
78 Assert.IsNotNull(van);
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
79
38
3c5657d99727 Cambio de setters de las propiedades a private
nelo@MTEySS.neluz.int
parents: 29
diff changeset
80 van.Actualizar(null, DateTime.Today.AddDays(5));
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
81 var r = agenda.Publicar(van.Titulo, string.Empty, van.Fecha);
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 52
diff changeset
82 Assert.IsFalse(r.Succeful);
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
83 }
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
84 }
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
85
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
86 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
87 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
88 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
89 var idEventoNoExistente = new Guid("99999999999999999999999999999999");
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
90
50
3ebe89c88caa Agregando propiedad al Evento sobre el Usuario que lo crea o que realizó la
nelopauselli
parents: 45
diff changeset
91 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
92
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
93 Assert.IsNull(agenda.GetEvento(idEventoNoExistente));
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
94 }
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
95
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
96 [Test]
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
97 public void Intentar_proponer_evento_sin_titulo()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
98 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
99 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
100
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
101 var agenda = new Agenda(null, null, repository.Object, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
102
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
103 var r = agenda.Proponer(string.Empty, null);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
104 Assert.IsFalse(r.Succeful);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
105
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
106 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
107 }
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
108
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
109 [Test]
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
110 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
111 {
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
112 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
113
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
114 SetCurrentUser(null);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
115
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
116 Assert.Throws<UsuarioNoAutenticadoException>(() => agenda.Proponer("Inmortalidad de la meduza.", null));
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
117 }
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
118
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
119 [Test]
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
120 public void Proponer_evento_correctamente()
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
121 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
122 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
123 agenda.Proponer("Van propuesta", null);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
124
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
125 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
126 Assert.IsNotNull(eventosPropuestos);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
127 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
128 Assert.AreEqual("Van propuesta", eventosPropuestos[0].Titulo);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
129 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
130
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
131 [Test]
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
132 public void Verificar_propuesta_separada_de_publicacion()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
133 {
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
134 var agenda = new Agenda(null, null, DefaultEventoRepository, DefaultPonenteRepository);
45
2edc705aae0a Coverage 100% sobre Agendas.Tests
juanjose.montesdeocaarbos
parents: 38
diff changeset
135
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
136 agenda.Proponer("Van propuesta", null);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
137 var r = agenda.Publicar("Van publicada", "jjmontes", DateTime.Now);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
138 Assert.IsTrue(r.Succeful);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
139
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
140 IList<Evento> eventosPropuestos = agenda.GetEventosPropuestos();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
141 IList<Evento> eventosPublicados = agenda.GetEventosPublicados();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
142
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
143 Assert.AreEqual(1, eventosPropuestos.Count);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
144 Assert.AreEqual(1, eventosPublicados.Count);
51
4a63a73e38e4 Cambio de nombres de test intentando describir mejor lo que verifican
nelopauselli
parents: 50
diff changeset
145 }
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
146 }
20
c5a99dde072f reorganizando tests
nelo@MTEySS.neluz.int
parents:
diff changeset
147 }