# HG changeset patch # User Nelo@Guinea.neluz.int # Date 1312230875 10800 # Node ID 5a1f7233aa5aedd19696e1d68623b63550330aa5 # Parent 3ca9fb66d39733ba33d35fb06c098fadb35faf54 Agregando algunos tests diff -r 3ca9fb66d397 -r 5a1f7233aa5a Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs --- 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); diff -r 3ca9fb66d397 -r 5a1f7233aa5a Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs --- 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(a => a.Property(p => p.Nombre, m => m.Unique(true))); mapper.Customize(a => a.Property(p => p.Twitter, m => m.Unique(true))); + mapper.Customize(a => a.Property(p => p.Titulo, m => m.Unique(true))); + mapper.AddPropertyPattern(p => p.DeclaringType == typeof(Evento) && p.Name == "Estado", a => a.Type()); var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes()); diff -r 3ca9fb66d397 -r 5a1f7233aa5a Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs --- 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() {