diff Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs @ 209:a36a76bd6ec3

Se soluciona ticket 173. Se agrega eliminación de personas siempre y cuando no esté asociada a ninguna van.
author alabra
date Wed, 24 Aug 2011 19:27:30 -0300
parents bfd472758bc3
children b9850b647a4e
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs	Wed Aug 24 11:30:06 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs	Wed Aug 24 19:27:30 2011 -0300
@@ -18,7 +18,7 @@
 			Persona persona=null;
 			personaRepository.Setup(r => r.Save(It.IsAny<Persona>())).Callback<Persona>(p => persona = p);
 
-			var personaService = new PersonaService(personaRepository.Object);
+            var personaService = new PersonaService(personaRepository.Object, DefaultEventoRepository);
 			
 			Assert.IsTrue(personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, "nelopauselli", "Nelo Pauselli"));
 			personaRepository.Verify(r=>r.Save(It.IsAny<Persona>()), Times.Once());
@@ -43,7 +43,7 @@
             var personaRepository = DefaultPersonaRepository;
 
             personaRepository.Save(new Persona("Mariano Pauselli", "marianopauselli@gmail.com", "marianopauselli", "http://marianopauselli.blogspot.com"));
-            var personaService = new PersonaService(personaRepository);
+            var personaService = new PersonaService(personaRepository, DefaultEventoRepository);
 
             Assert.IsTrue(personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, "marianopauselli", "Mariano Pauselli"));
 
@@ -66,7 +66,7 @@
         {
             var personaRepository = DefaultPersonaRepository;
 
-            var personaService = new PersonaService(personaRepository);
+            var personaService = new PersonaService(personaRepository, DefaultEventoRepository);
 			var r = personaService.Add("Mariano Pauselli", "marianopauselli", string.Empty, string.Empty, null);
             Assert.IsTrue(r.Succeful);
 
@@ -97,8 +97,8 @@
             var p1 = personaRepository.GetByTwitter("nelopauselli");
             Assert.IsNotNull(p1);
             Assert.AreEqual(1, p1.Cuentas.Count());
-            
-            var personaService = new PersonaService(personaRepository);
+
+            var personaService = new PersonaService(personaRepository, DefaultEventoRepository);
 
             personaService.AddCuenta(IdentityProviderEnum.Google, "nelopauselli");
 
@@ -136,10 +136,51 @@
 		public void Modificar_persona_inexistente()
 		{
 			var personaRepository = DefaultPersonaRepository;
-			var personaService = new PersonaService(personaRepository);
+            var personaService = new PersonaService(personaRepository, DefaultEventoRepository);
 			var r = personaService.Update(new Guid(), "Mariano Pauselli", "marianopauselli", "marianopauselli@gmail.com", string.Empty, null);
 
 			Assert.IsFalse(r.Succeful);
 		}
+
+        [Test]
+        public void Eliminar_persona_no_asociado_van()
+        {
+            var personaRepository = DefaultPersonaRepository;
+
+            var personaService = new PersonaService(personaRepository, DefaultEventoRepository);
+            var r = personaService.Add("Alejandro Labra", "alabras", "alejandro.labra@gmail.com", string.Empty, null);
+            Assert.IsTrue(r.Succeful);
+            
+            var persona = personaRepository.GetByNombre("Alejandro Labra");
+            Assert.IsNotNull(persona);
+
+            var delete = personaService.Delete(persona.Id);
+            Assert.IsTrue(delete.Succeful);
+        }
+
+        [Test]
+        public void Eliminar_persona_asociado_vans()
+        {
+            var publicador = new Mock<IPublicador>();
+            var personaService = new PersonaService(DefaultPersonaRepository, DefaultEventoRepository);
+
+            var agenda = new Agenda(publicador.Object, DefaultEventoRepository, DefaultPersonaRepository);
+
+            var fechaInicio = DateTime.Now.ToUniversalTime();
+            var fechaTermino = fechaInicio.AddHours(2);
+            agenda.Agendar("Van para publicar", TestsHelper.GetOrCreatePonente("alabra"), fechaInicio, fechaTermino,
+                           "http://groups.google.com/group/altnet-hispano/browse_thread/thread/65d6d26eb381386e", TipoEvento.Van);
+
+            Assert.AreEqual(0, agenda.GetEventosActivos(EventoPropuestoState.GetInstance()).Count);
+
+            var eventos = agenda.GetEventosActivos();
+            Assert.AreEqual(1, eventos.Count);
+
+            var evento = eventos[0];
+            Assert.IsNotNull(evento.Ponente);
+
+            var delete = personaService.Delete(evento.Ponente.Id);
+            Assert.IsFalse(delete.Succeful);
+        }
 	}
 }
\ No newline at end of file