Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowTests.cs @ 222:68b09c30b0d2
Separando los test de persistencia en un proyecto aparte
author | nelopauselli |
---|---|
date | Mon, 19 Sep 2011 18:18:17 -0300 |
parents | |
children | 72a96459f910 |
comparison
equal
deleted
inserted
replaced
221:37ddf81333d3 | 222:68b09c30b0d2 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using Agendas.Repositories.Tests.Infraestructure; | |
4 using AltNetHispano.Agendas.Domain; | |
5 using AltNetHispano.Agendas.Domain.Repositories; | |
6 using Moq; | |
7 using NUnit.Framework; | |
8 | |
9 namespace Agendas.Repositories.Tests | |
10 { | |
11 public abstract class WorkflowTests<T> where T : IInfraestrutureFactory, new() | |
12 { | |
13 private readonly IPersonaRepository _personaRepository; | |
14 private readonly IEventoRepository _eventoRepository; | |
15 private readonly Func<IDisposable> _requestEmulator; | |
16 | |
17 protected WorkflowTests() | |
18 { | |
19 var infraestrutureFactory = new T(); | |
20 | |
21 _eventoRepository = infraestrutureFactory.GetEventoRepository(); | |
22 _personaRepository = infraestrutureFactory.GetPonenteRepository(); | |
23 _requestEmulator = infraestrutureFactory.GetRequestEmulator(); | |
24 } | |
25 | |
26 [SetUp] | |
27 public void SetearUsuario() | |
28 { | |
29 var seguridad = new Mock<ISeguridad>(); | |
30 seguridad.Setup(s => s.GetUserName()).Returns("neluz"); | |
31 IdentityContext.Init(seguridad.Object, _personaRepository); | |
32 } | |
33 | |
34 [Test] | |
35 public void Proponer() | |
36 { | |
37 var publicador = new Mock<IPublicador>(); | |
38 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
39 | |
40 workflow.Proponer(); | |
41 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Once()); | |
42 } | |
43 | |
44 [Test] | |
45 public void Proponer_y_agendar() | |
46 { | |
47 var publicador = new Mock<IPublicador>(); | |
48 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
49 | |
50 workflow.Proponer(); | |
51 | |
52 workflow.Agendar(); | |
53 | |
54 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(2)); | |
55 } | |
56 [Test] | |
57 public void Proponer_agendar_y_cancelar() | |
58 { | |
59 var publicador = new Mock<IPublicador>(); | |
60 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
61 | |
62 workflow.Proponer(); | |
63 | |
64 workflow.Agendar(); | |
65 | |
66 workflow.Cancelar(); | |
67 | |
68 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(3)); | |
69 } | |
70 | |
71 [Test] | |
72 public void Proponer_agendar_cancelar_y_reagendar() | |
73 { | |
74 var publicador = new Mock<IPublicador>(); | |
75 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
76 | |
77 workflow.Proponer(); | |
78 | |
79 workflow.Agendar(); | |
80 | |
81 workflow.Cancelar(); | |
82 | |
83 workflow.ReAgendar(); | |
84 | |
85 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); | |
86 } | |
87 | |
88 [Test] | |
89 public void Proponer_agendar_cancelar_reproponer_agendar_y_confirmar() | |
90 { | |
91 var publicador = new Mock<IPublicador>(); | |
92 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
93 | |
94 workflow.Proponer(); | |
95 | |
96 workflow.Agendar(); | |
97 | |
98 workflow.Cancelar(); | |
99 | |
100 workflow.ReProponer(); | |
101 | |
102 workflow.Agendar(); | |
103 | |
104 workflow.Confirmar(); | |
105 | |
106 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(6)); | |
107 } | |
108 | |
109 [Test] | |
110 public void Proponer_agendar_cancelar_reagendar_y_confirmar() | |
111 { | |
112 var publicador = new Mock<IPublicador>(); | |
113 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
114 | |
115 workflow.Proponer(); | |
116 | |
117 workflow.Agendar(); | |
118 | |
119 workflow.Cancelar(); | |
120 | |
121 workflow.ReAgendar(); | |
122 | |
123 workflow.Confirmar(); | |
124 | |
125 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(5)); | |
126 } | |
127 | |
128 [Test] | |
129 public void Proponer_agendar_cancelar_y_reproponer() | |
130 { | |
131 var publicador = new Mock<IPublicador>(); | |
132 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
133 | |
134 workflow.Proponer(); | |
135 | |
136 workflow.Agendar(); | |
137 | |
138 workflow.Cancelar(); | |
139 | |
140 workflow.ReProponer(); | |
141 | |
142 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); | |
143 } | |
144 | |
145 [Test] | |
146 public void Proponer_y_descartar() | |
147 { | |
148 var publicador = new Mock<IPublicador>(); | |
149 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
150 | |
151 workflow.Proponer(); | |
152 | |
153 workflow.Descartar(); | |
154 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(2)); | |
155 } | |
156 | |
157 [Test] | |
158 public void Proponer_agendar_cancelar_y_descartar() | |
159 { | |
160 var publicador = new Mock<IPublicador>(); | |
161 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
162 | |
163 workflow.Proponer(); | |
164 | |
165 workflow.Agendar(); | |
166 | |
167 workflow.Cancelar(); | |
168 | |
169 workflow.Descartar(); | |
170 | |
171 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); | |
172 } | |
173 | |
174 [Test] | |
175 public void Proponer_agendar_y_confirmar() | |
176 { | |
177 var publicador = new Mock<IPublicador>(); | |
178 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
179 | |
180 workflow.Proponer(); | |
181 | |
182 workflow.Agendar(); | |
183 | |
184 workflow.Confirmar(); | |
185 | |
186 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(3)); | |
187 } | |
188 | |
189 [Test] | |
190 public void Proponer_agendar_confirmar_publicar() | |
191 { | |
192 var publicador = new Mock<IPublicador>(); | |
193 var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); | |
194 | |
195 workflow.Proponer(); | |
196 | |
197 workflow.Agendar(); | |
198 | |
199 workflow.Confirmar(); | |
200 | |
201 workflow.Publicar(); | |
202 | |
203 publicador.Verify(p => p.Publicar(It.IsAny<IEnumerable<Track>>()), Times.Exactly(4)); | |
204 } | |
205 } | |
206 } |