changeset 147:5a1f7233aa5a

Agregando algunos tests
author Nelo@Guinea.neluz.int
date Mon, 01 Aug 2011 17:34:35 -0300
parents 3ca9fb66d397
children c99636fbdc5f 157492228830
files Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs
diffstat 3 files changed, 57 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs	Mon Aug 01 11:42:50 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs	Mon Aug 01 17:34:35 2011 -0300
@@ -14,12 +14,6 @@
 			_personaRepository = personaRepository;
 		}
 
-		public bool Validate(IdentityProviderEnum identityProvider, string username)
-		{
-			var cuenta = _personaRepository.GetCuenta(identityProvider, username);
-			return cuenta != null;
-		}
-
 		public bool CreateIfNotExist(IdentityProviderEnum identityProvider, string username, string nombre)
 		{
 			var cuenta = _personaRepository.GetCuenta(identityProvider, username);
--- a/Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs	Mon Aug 01 11:42:50 2011 -0300
+++ b/Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs	Mon Aug 01 17:34:35 2011 -0300
@@ -37,6 +37,8 @@
 			    mapper.Customize<Persona>(a => a.Property(p => p.Nombre, m => m.Unique(true)));
                 mapper.Customize<Persona>(a => a.Property(p => p.Twitter, m => m.Unique(true)));
 
+                mapper.Customize<Evento>(a => a.Property(p => p.Titulo, m => m.Unique(true)));
+
 				mapper.AddPropertyPattern(p => p.DeclaringType == typeof(Evento) && p.Name == "Estado", a => a.Type<EventoStateType>());
 
 				var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes());
--- 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()
 		{