diff Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs @ 147:5a1f7233aa5a

Agregando algunos tests
author Nelo@Guinea.neluz.int
date Mon, 01 Aug 2011 17:34:35 -0300
parents 2dbb15f4510f
children f17252543cbf
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs	Mon Aug 01 11:42:50 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs	Mon Aug 01 17:34:35 2011 -0300
@@ -60,6 +60,61 @@
             Assert.AreEqual(1, persona.Cuentas.Count());
         }
 
+        [Test]
+        public void Agregar_y_modificar_persona()
+        {
+            var personaRepository = DefaultPersonaRepository;
+
+            var personaService = new PersonaService(personaRepository);
+            var r = personaService.Add("Mariano Pauselli", "marianopauselli", string.Empty);
+            Assert.IsTrue(r.Succeful);
+
+            var todas = personaService.GetAll();
+            Assert.AreEqual(2, todas.Count());
+
+            var p1 = todas.SingleOrDefault(p => p.Nombre == "Mariano Pauselli");
+            Assert.IsNotNull(p1);
+            
+            var personaId = p1.Id;
+            var p2 = personaService.GetById(personaId);
+
+            Assert.AreEqual(p1, p2);
+            Assert.AreSame(p1, p2);
+
+            personaService.Update(personaId, p1.Nombre, p1.Twitter, "marianopauselli@gmail.com");
+
+            var p3 = personaService.GetById(personaId);
+            Assert.IsNotNull(p3);
+            Assert.AreEqual("marianopauselli@gmail.com",p3.Mail);
+        }
+
+        [Test]
+        public void Agregar_y_modificar_cuenta()
+        {
+            var personaRepository = DefaultPersonaRepository;
+
+            var p1 = personaRepository.GetByTwitter("nelopauselli");
+            Assert.IsNotNull(p1);
+            Assert.AreEqual(1, p1.Cuentas.Count());
+            
+            var personaService = new PersonaService(personaRepository);
+
+            personaService.AddCuenta(IdentityProviderEnum.Google, "nelopauselli");
+
+            var p2 = personaRepository.GetByTwitter("nelopauselli");
+            Assert.IsNotNull(p2);
+            Assert.AreEqual(2, p2.Cuentas.Count());
+
+            var personaId = p2.Id;
+
+            personaService.RemoveCuenta(IdentityProviderEnum.Google, "nelopauselli");
+            Assert.AreEqual(1, personaRepository.Get(personaId).Cuentas.Count());
+
+            personaService.RemoveCuenta(IdentityProviderEnum.Twitter, "nelopauselli");
+            Assert.AreEqual(0, personaRepository.Get(personaId).Cuentas.Count());
+
+        }
+
 		[Test]
 		public void IdentificacionGoogle()
 		{