# HG changeset patch # User nelopauselli # Date 1316467097 10800 # Node ID 68b09c30b0d2ae1f5e1dc470314079d366a1509f # Parent 37ddf81333d39b630f1b0e6620cd68b618920ce1 Separando los test de persistencia en un proyecto aparte diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs --- a/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs Mon Sep 19 18:18:17 2011 -0300 @@ -15,4 +15,20 @@ void Update(Evento evento); bool ExistePonente(Persona ponente); } + + public class EventoStateRepository + { + public static IEnumerable All + { + get + { + return new[] + { + EventoNullState.GetInstance(), EventoPropuestoState.GetInstance(), EventoAgendadoState.GetInstance(), + EventoConfirmadoState.GetInstance(), EventoPublicadoState.GetInstance(), EventoCanceladoState.GetInstance(), + EventoDescartadoState.GetInstance() + }; + } + } + } } \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj --- a/Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj Mon Sep 19 18:18:17 2011 -0300 @@ -31,10 +31,13 @@ 4 - - ..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll - - + + ..\packages\Iesi.Collections.3.1.0.4000\lib\Net35\Iesi.Collections.dll + + + ..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll + + @@ -74,6 +77,9 @@ Agendas.Twitter + + + + \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/App.config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/App.config Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,25 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrud.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrud.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,186 @@ +using System; +using System.Linq; +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; +using Moq; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + public abstract class EventoCrud where T : IInfraestrutureFactory, new() + { + private readonly IEventoRepository _eventoRepository; + private readonly Func _requestEmulator; + private readonly IPersonaRepository _personaRepository; + + protected EventoCrud() + { + var infraestrutureFactory = new T(); + + _eventoRepository = infraestrutureFactory.GetEventoRepository(); + _personaRepository = infraestrutureFactory.GetPonenteRepository(); + _requestEmulator = infraestrutureFactory.GetRequestEmulator(); + } + + [SetUp] + public void SetearUsuario() + { + var seguridad = new Mock(); + seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + IdentityContext.Init(seguridad.Object, _personaRepository); + } + + [Test] + public void Create() + { + Assert.AreNotEqual(Guid.Empty, CreateEvento()); + } + + private Guid CreateEvento() + { + using (_requestEmulator.Invoke()) + { + var ponente = new Persona("Carlos Blé") {Twitter = "carlosble"}; + _personaRepository.Save(ponente); + + var usuario = new Persona("Nelo") {Twitter = "nelopauselli"}; + _personaRepository.Save(usuario); + + var evento = Evento.Proponer("TDD - Diseño Basado en Ejemplos", ponente, string.Empty, TipoEvento.Van); + evento.Tracks.First().LogAdd(new TrackLog(TrackLogPropietario.Twitter, "Mensaje", usuario, true)); + + _eventoRepository.Save(evento); + + return evento.Id; + } + } + + [Test] + public void Read() + { + Guid eventoId = CreateEvento(); + + using (_requestEmulator.Invoke()) + { + Evento van = _eventoRepository.Get(eventoId); + + Assert.IsNotNull(van); + Assert.IsNotNull(van.Ponente); + Assert.AreEqual("Carlos Blé", van.Ponente.Nombre); + + var track1 = van.Tracks.Where(t => t.Accion == Accion.Proponer).FirstOrDefault(); + Assert.IsNotNull(track1); + Assert.AreEqual(van, track1.Evento); + + Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo); + } + } + + [Test] + public void Update() + { + Guid eventoId = CreateEvento(); + var fechaInicio = new DateTime(2010, 04, 17).ToUniversalTime(); + var fechaTermino = fechaInicio.AddHours(2); + + using (_requestEmulator.Invoke()) + { + Evento van = _eventoRepository.Get(eventoId); + + Assert.IsNotNull(van); + + van.CambiarTitulo("TDD & Ejemplos"); + + var otroPonente = new Persona("José"); + _personaRepository.Save(otroPonente); + + van.Actualizar(otroPonente, fechaInicio, fechaTermino, null); + + _eventoRepository.Update(van); + } + + using (_requestEmulator.Invoke()) + { + Evento van = _eventoRepository.Get(eventoId); + + Assert.IsNotNull(van); + Assert.IsNotNull(van.Ponente); + Assert.AreEqual("José", van.Ponente.Nombre); + Assert.AreEqual("TDD & Ejemplos", van.Titulo); + Assert.AreEqual(new DateTime(2010, 04, 17).ToUniversalTime(), van.FechaInicio); + Assert.AreEqual(fechaTermino, van.FechaTermino); + + var ponente1 = _personaRepository.GetByNombre("Carlos Blé"); + Assert.IsNotNull(ponente1); + + var ponente2 = _personaRepository.GetByNombre("José"); + Assert.IsNotNull(ponente2); + + Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Proponer).Count()); + Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Modificar).Count()); + } + } + + [Test] + public void Delete() + { + Guid eventoId = CreateEvento(); + + using (_requestEmulator.Invoke()) + { + Evento van = _eventoRepository.Get(eventoId); + Assert.IsNotNull(van); + + _eventoRepository.Delete(van); + } + + using (_requestEmulator.Invoke()) + { + Evento van = _eventoRepository.Get(eventoId); + + Assert.IsNull(van); + + var ponente = _personaRepository.GetByNombre("Carlos Blé"); + + Assert.IsNotNull(ponente); + } + } + + [Test] + public void Workflow() + { + Guid eventoId = CreateEvento(); + + using (_requestEmulator.Invoke()) + { + Evento evento = _eventoRepository.Get(eventoId); + Assert.AreEqual(EventoPropuestoState.GetInstance(), evento.Estado); + + evento.Agendar(evento.Ponente, evento.FechaInicio, evento.FechaTermino, null); + } + + using (_requestEmulator.Invoke()) + { + Evento evento = _eventoRepository.Get(eventoId); + Assert.AreEqual(EventoAgendadoState.GetInstance(), evento.Estado); + + evento.Confirmar(); + } + + using (_requestEmulator.Invoke()) + { + Evento evento = _eventoRepository.Get(eventoId); + Assert.AreEqual(EventoConfirmadoState.GetInstance(), evento.Estado); + + evento.Publicar(1, null, new TimeSpan(0, 0, 0)); + } + + using (_requestEmulator.Invoke()) + { + Evento evento = _eventoRepository.Get(eventoId); + Assert.AreEqual(EventoPublicadoState.GetInstance(), evento.Estado); + } + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrudMemory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrudMemory.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,18 @@ +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Repositories.Memory; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class EventoCrudMemory : EventoCrud + { + [SetUp] + public void BorrarRepositorios() + { + EventoRepository.Clear(); + PersonaRepository.Clear(); + } + + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrudNh.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/EventoCrudNh.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,15 @@ +using Agendas.Repositories.Tests.Infraestructure; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class EventoCrudNh : EventoCrud + { + [SetUp] + public void BorrarRepositorios() + { + NhHelperTest.CleanDb(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/IInfraestrutureFactory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/IInfraestrutureFactory.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,12 @@ +using System; +using AltNetHispano.Agendas.Domain.Repositories; + +namespace Agendas.Repositories.Tests.Infraestructure +{ + public interface IInfraestrutureFactory + { + IEventoRepository GetEventoRepository(); + IPersonaRepository GetPonenteRepository(); + Func GetRequestEmulator(); + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/MemoryInfraestrutureFactory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/MemoryInfraestrutureFactory.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,25 @@ +using System; +using AltNetHispano.Agendas.Domain.Repositories; +using AltNetHispano.Agendas.Repositories.Memory; +using Moq; + +namespace Agendas.Repositories.Tests.Infraestructure +{ + public class MemoryInfraestrutureFactory : IInfraestrutureFactory + { + public IEventoRepository GetEventoRepository() + { + return new EventoRepository(); + } + + public IPersonaRepository GetPonenteRepository() + { + return new PersonaRepository(); + } + + public Func GetRequestEmulator() + { + return () => new Mock().Object; + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/NhHelperTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/NhHelperTest.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,16 @@ +using Agendas.NHibernate; + +namespace Agendas.Repositories.Tests.Infraestructure +{ + public static class NhHelperTest + { + public static void CleanDb() + { + var sf = NhHelper.GetSessionFactory(); + + var session = sf.OpenStatelessSession(); + session.CreateSQLQuery("DELETE FROM Evento").ExecuteUpdate(); + session.CreateSQLQuery("DELETE FROM Persona").ExecuteUpdate(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/NhInfraestrutureFactory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/NhInfraestrutureFactory.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,32 @@ +using System; +using Agendas.NHibernate; +using AltNetHispano.Agendas.Domain.Repositories; +using AltNetHispano.Agendas.Repositories.NHibernate; +using NHibernate; + +namespace Agendas.Repositories.Tests.Infraestructure +{ + public class NhInfraestrutureFactory:IInfraestrutureFactory + { + private readonly ISessionFactory _sessionFactory; + + public NhInfraestrutureFactory() + { + _sessionFactory = NhHelper.GetSessionFactory(); + } + public IEventoRepository GetEventoRepository() + { + return new EventoRepository(_sessionFactory); + } + + public IPersonaRepository GetPonenteRepository() + { + return new PersonaRepository(_sessionFactory); + } + + public Func GetRequestEmulator() + { + return () => new RequestEmulator(_sessionFactory); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/RequestEmulator.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Infraestructure/RequestEmulator.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,23 @@ +using System; +using NHibernate; +using NHibernate.Context; + +namespace Agendas.Repositories.Tests.Infraestructure +{ + public class RequestEmulator : IDisposable + { + private readonly ISession _session; + + public RequestEmulator(ISessionFactory sessionFactory) + { + _session = sessionFactory.OpenSession(); + CurrentSessionContext.Bind(_session); + } + + public void Dispose() + { + _session.Flush(); + _session.Close(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrud.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrud.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,84 @@ +namespace Agendas.Repositories.Tests +{ + //public class PatrocinadorCrud + //{ + // private readonly IPatrocinadorRepository _patrocinadorRepository; + // private readonly Func _requestEmulator; + // private byte[] _logo; + + // public PatrocinadorCrud(Func createPatrocinadorRepository, Func requestEmulator) + // { + // _patrocinadorRepository = createPatrocinadorRepository.Invoke(); + // _requestEmulator = requestEmulator; + // } + + // public Guid Create() + // { + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = new Patrocinador("APRESS"); + + // patrocinador.LoadLogo("images/apress.gif"); + // _logo = patrocinador.Logo; + + // _patrocinadorRepository.Save(patrocinador); + // return patrocinador.Id; + // } + // } + + // public void Read() + // { + // Guid patrocinadorId = Create(); + + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); + + // Assert.IsNotNull(patrocinador); + // Assert.AreEqual("APRESS", patrocinador.Nombre); + // Assert.IsNotNull(patrocinador.Logo); + // Assert.AreEqual(_logo, patrocinador.Logo); + // } + // } + + // public void Update() + // { + // Guid patrocinadorId = Create(); + + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); + // Assert.IsNotNull(patrocinador); + + // patrocinador.Nombre = "Apress"; + // } + + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); + + // Assert.IsNotNull(patrocinador); + // Assert.AreEqual("Apress", patrocinador.Nombre); + // } + // } + + // public void Delete() + // { + // Guid patrocinadorId = Create(); + + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); + // Assert.IsNotNull(patrocinador); + + // _patrocinadorRepository.Delete(patrocinador); + // } + + // using (_requestEmulator.Invoke()) + // { + // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); + // Assert.IsNull(patrocinador); + // } + // } + //} +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrudMemoryTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrudMemoryTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,57 @@ +namespace Agendas.Repositories.Tests +{ + //[TestFixture] + //public class PatrocinadorCrudMemoryTests + //{ + // private PatrocinadorCrud _eventoCrud; + + // #region SetUp + + // [SetUp] + // public void BorrarRepositorios() + // { + // PatrocinadorRepository.Clear(); + // } + + // [SetUp] + // public void SetearUsuario() + // { + // var seguridad = new Mock(); + // seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + // IdentityContext.Init(seguridad.Object, new PersonaRepository()); + // } + + // [SetUp] + // public void CreateCrud() + // { + // _eventoCrud = new PatrocinadorCrud(() => new PatrocinadorRepository(), () => new Mock().Object); + // } + + // #endregion + + // [Test] + // public void Create() + // { + // _eventoCrud.Create(); + // } + + // [Test] + // public void Read() + // { + // _eventoCrud.Read(); + // } + + // [Test] + // public void Update() + // { + // _eventoCrud.Update(); + // } + + // [Test] + // public void Delete() + // { + // _eventoCrud.Delete(); + // } + + //} +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrudNhTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PatrocinadorCrudNhTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,58 @@ +namespace Agendas.Repositories.Tests +{ + //[TestFixture] + //public class PatrocinadorCrudNhTests + //{ + // private PatrocinadorCrud _patrocinadorCrud; + + // #region SetUp + + // [SetUp] + // public void BorrarRepositorios() + // { + // NhHelperTest.CleanDb(); + // } + + // [SetUp] + // public void SetearUsuario() + // { + // var seguridad = new Mock(); + // seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + // IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory())); + // } + + // [SetUp] + // public void CreateCrud() + // { + // ISessionFactory sessionFactory = NhHelper.GetSessionFactory(); + // _patrocinadorCrud = new PatrocinadorCrud(() => new PatrocinadorRepository(sessionFactory), () => new RequestEmulator(sessionFactory)); + // } + + // #endregion + + // [Test] + // public void Create() + // { + // _patrocinadorCrud.Create(); + // } + + // [Test] + // public void Read() + // { + // _patrocinadorCrud.Read(); + // } + + // [Test] + // public void Update() + // { + // _patrocinadorCrud.Update(); + // } + + // [Test] + // public void Delete() + // { + // _patrocinadorCrud.Delete(); + // } + + //} +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrud.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrud.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,187 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; +using AltNetHispano.Agendas.Domain.Services; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + public abstract class PersonaCrud where T : IInfraestrutureFactory, new() + { + private readonly IPersonaRepository _personaRepository; + private readonly Func _requestEmulator; + private readonly PersonaService _personaService; + private readonly IEventoRepository _eventoRepository; + + protected PersonaCrud() + { + var infraestrutureFactory = new T(); + + _eventoRepository = infraestrutureFactory.GetEventoRepository(); + _personaRepository = infraestrutureFactory.GetPonenteRepository(); + _requestEmulator = infraestrutureFactory.GetRequestEmulator(); + + _personaService = new PersonaService(_personaRepository, _eventoRepository); + } + + [Test] + public void CreateAdministrador() + { + Guid id; + using (_requestEmulator.Invoke()) + { + var r = CreatePersona("Nelo Pauselli", "nelopauselli", "nelopauselli@gmail.com", "http://nelopauselli.blogspot.com", + null); + Assert.AreEqual("Nelo Pauselli", r.Nombre); + Assert.AreNotEqual(Guid.Empty, r.Id); + + id = r.Id; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.GetByNombre("Nelo Pauselli"); + Assert.IsNotNull(persona); + Assert.AreEqual(id, persona.Id); + } + } + + private ResultadoAdd CreatePersona(string nombre, string twitter, string mail, string blog, IEnumerable roles) + { + return _personaService.Add(nombre, twitter, mail, blog, roles); + } + + [Test] + public void ReadAdministrador() + { + Guid personaId; + using (_requestEmulator.Invoke()) + { + var r = CreatePersona("Nelo Pauselli", "nelopauselli", "nelopauselli@gmail.com", "http://nelopauselli.blogspot.com", + null); + personaId = r.Id; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + + Assert.IsNotNull(persona); + Assert.AreEqual("Nelo Pauselli", persona.Nombre); + Assert.AreEqual("nelopauselli", persona.Twitter); + Assert.AreEqual("nelopauselli@gmail.com", persona.Mail); + Assert.AreEqual("http://nelopauselli.blogspot.com", persona.Blog); + + Assert.IsTrue(persona.Cuentas.Any()); + Assert.AreEqual("nelopauselli", persona.Cuentas.First().LogonName); + Assert.AreEqual(IdentityProviderEnum.Twitter, persona.Cuentas.First().IdentityProvider); + + Assert.IsTrue(persona.Roles.Any()); + Assert.IsTrue(persona.Roles.Contains(Roles.Usuario)); + Assert.IsTrue(persona.Roles.Contains(Roles.Administrador)); + } + } + + [Test] + public void CreateUsuario() + { + using (_requestEmulator.Invoke()) + { + CreatePersona("Pablo Morales", "pablomorales", "pablomorales@gmail.com", "http://pablomorales.blogspot.com", + new[] {Roles.Usuario}); + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.GetByNombre("Pablo Morales"); + Assert.IsNotNull(persona); + } + } + + [Test] + public void ReadUsuario() + { + Guid personaId; + using (_requestEmulator.Invoke()) + { + var r = CreatePersona("Pablo Morales", "pablomorales", "pablomorales@gmail.com", "http://pablomorales.blogspot.com", + new[] {Roles.Usuario}); + personaId = r.Id; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + + Assert.IsNotNull(persona); + Assert.AreEqual("Pablo Morales", persona.Nombre); + Assert.AreEqual("pablomorales", persona.Twitter); + Assert.AreEqual("pablomorales@gmail.com", persona.Mail); + Assert.AreEqual("http://pablomorales.blogspot.com", persona.Blog); + + Assert.IsTrue(persona.Cuentas.Any()); + Assert.AreEqual("pablomorales", persona.Cuentas.First().LogonName); + Assert.AreEqual(IdentityProviderEnum.Twitter, persona.Cuentas.First().IdentityProvider); + + Assert.IsTrue(persona.Roles.Any()); + Assert.IsTrue(persona.Roles.Contains(Roles.Usuario)); + Assert.IsFalse(persona.Roles.Contains(Roles.Administrador)); + } + } + + [Test] + public void Update() + { + Guid personaId; + using (_requestEmulator.Invoke()) + { + var r = CreatePersona("Nelo Pauselli", "nelopauselli", "nelopauselli@gmail.com", "http://nelopauselli.blogspot.com", + null); + personaId = r.Id; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + Assert.IsNotNull(persona); + + persona.Nombre = "Nelo Mariano Pauselli"; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + + Assert.IsNotNull(persona); + Assert.AreEqual("Nelo Mariano Pauselli", persona.Nombre); + } + } + + [Test] + public void Delete() + { + Guid personaId; + using (_requestEmulator.Invoke()) + { + var r = CreatePersona("Nelo Pauselli", "nelopauselli", "nelopauselli@gmail.com", + "http://nelopauselli.blogspot.com", null); + personaId = r.Id; + } + + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + Assert.IsNotNull(persona); + _personaService.Delete(personaId); + } + using (_requestEmulator.Invoke()) + { + var persona = _personaRepository.Get(personaId); + Assert.IsNull(persona); + } + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrudMemoryTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrudMemoryTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,16 @@ +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Repositories.Memory; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class PersonaCrudMemoryTests : PersonaCrud + { + [SetUp] + public void BorrarRepositorios() + { + PersonaRepository.Clear(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrudNhTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/PersonaCrudNhTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,15 @@ +using Agendas.Repositories.Tests.Infraestructure; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class PersonaCrudNhTests : PersonaCrud + { + [SetUp] + public void BorrarRepositorios() + { + NhHelperTest.CleanDb(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Properties/AssemblyInfo.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Agendas.Repositories.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Agendas.Repositories.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d96f300a-bf61-4c17-a4bd-f8d38f6f29e7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/SchemaNhTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/SchemaNhTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,62 @@ +using System; +using System.Xml; +using System.Xml.Serialization; +using Agendas.NHibernate; +using Agendas.Repositories.Tests.Infraestructure; +using NHibernate.Cfg.MappingSchema; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class SchemaNhTests + { + [Test] + public void ValidateSchema() + { + var cfg = NhHelper.GetConfiguration(); + + var schemaValidator = new SchemaValidator(cfg); + schemaValidator.Validate(); + } + + [Test] + public void BuildSessionFactory() + { + var cfg = NhHelper.GetConfiguration(); + + var sessionfactory = cfg.BuildSessionFactory(); + + Assert.IsNotNull(sessionfactory); + } + + [Test] + public void ShowMapping() + { + var mapping = NhHelper.GetMapping(); + + var setting = new XmlWriterSettings { Indent = true }; + + var serializer = new XmlSerializer(typeof(HbmMapping)); + + var xw = XmlWriter.Create(Console.Out, setting); + + serializer.Serialize(xw, mapping); + } + + [Test] + public void LimpiarDb() + { + NhHelperTest.CleanDb(); + + var sf = NhHelper.GetSessionFactory(); + + var session = sf.OpenSession(); + + var query = session.CreateQuery("from System.Object"); + + Assert.IsEmpty(query.List()); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/TestsHelper.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/TestsHelper.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,28 @@ +using System; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; + +namespace Agendas.Repositories.Tests +{ + public class TestsHelper + { + private readonly IPersonaRepository _repository; + + public TestsHelper(IPersonaRepository repository) + { + _repository = repository; + } + + public Guid GetOrCreatePonente(string nombre) + { + var persona = _repository.GetByNombre(nombre); + if (persona == null) + { + persona = new Persona(nombre) { Twitter = nombre.Replace(" ", string.Empty).ToLower() }; + _repository.Save(persona); + } + return persona.Id; + } + + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/Workflow.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/Workflow.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,117 @@ +using System; +using System.Linq; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + internal class Workflow + { + private readonly Func _requestEmulator; + private readonly Agenda _agenda; + private readonly IEventoRepository _eventoRepository; + private Guid _eventoId; + private readonly TestsHelper _testsHelper; + + public Workflow(IPublicador publicador, IEventoRepository eventoRepository, IPersonaRepository personaRepository, + Func requestEmulator) + { + _requestEmulator = requestEmulator; + _eventoRepository = eventoRepository; + + _agenda = new Agenda(publicador, eventoRepository, personaRepository); + _testsHelper = new TestsHelper(personaRepository); + } + + public void Proponer() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.Proponer("SOLID", _testsHelper.GetOrCreatePonente("Jorge"), null, TipoEvento.Van); + Assert.IsTrue(resultado.Succeful); + } + + GetId(); + } + + + public void Agendar() + { + using (_requestEmulator.Invoke()) + { + var fechaInicio = DateTime.Today.AddDays(5).ToUniversalTime(); + var fechaTermino = fechaInicio.AddHours(2); + var resultado = _agenda.Agendar("SOLID", _testsHelper.GetOrCreatePonente("Jorge"), fechaInicio, fechaTermino, null, + TipoEvento.Van); + Assert.IsTrue(resultado.Succeful); + } + + GetId(); + } + + private void GetId() + { + using (_requestEmulator.Invoke()) + { + var evento = _eventoRepository.GetActivos().SingleOrDefault(); + Assert.IsNotNull(evento); + _eventoId = evento.Id; + } + } + + public void Confirmar() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.Confirmar(_eventoId); + Assert.IsTrue(resultado.Succeful); + } + } + + public void Publicar() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.Publicar(_eventoId, 1, "http://www.altnethispano.org/", new TimeSpan(2, 11, 0)); + Assert.IsTrue(resultado.Succeful); + } + } + + public void Cancelar() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.Cancelar(_eventoId); + Assert.IsTrue(resultado.Succeful); + } + } + + public void Descartar() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.Descartar(_eventoId); + Assert.IsTrue(resultado.Succeful); + } + } + + public void ReProponer() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.ReProponer(_eventoId); + Assert.IsTrue(resultado.Succeful); + } + } + + public void ReAgendar() + { + using (_requestEmulator.Invoke()) + { + var resultado = _agenda.ReAgendar(_eventoId); + Assert.IsTrue(resultado.Succeful); + } + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowMemoryTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowMemoryTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,18 @@ +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Repositories.Memory; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class WorkflowMemoryTests : WorkflowTests + { + [SetUp] + public void BorrarRepositorios() + { + EventoRepository.Clear(); + PersonaRepository.Clear(); + } + + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowNhTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowNhTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,15 @@ +using Agendas.Repositories.Tests.Infraestructure; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + [TestFixture] + public class WorkflowNhTests : WorkflowTests + { + [SetUp] + public void BorrarRepositorios() + { + NhHelperTest.CleanDb(); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowTests.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/WorkflowTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using Agendas.Repositories.Tests.Infraestructure; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; +using Moq; +using NUnit.Framework; + +namespace Agendas.Repositories.Tests +{ + public abstract class WorkflowTests where T : IInfraestrutureFactory, new() + { + private readonly IPersonaRepository _personaRepository; + private readonly IEventoRepository _eventoRepository; + private readonly Func _requestEmulator; + + protected WorkflowTests() + { + var infraestrutureFactory = new T(); + + _eventoRepository = infraestrutureFactory.GetEventoRepository(); + _personaRepository = infraestrutureFactory.GetPonenteRepository(); + _requestEmulator = infraestrutureFactory.GetRequestEmulator(); + } + + [SetUp] + public void SetearUsuario() + { + var seguridad = new Mock(); + seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + IdentityContext.Init(seguridad.Object, _personaRepository); + } + + [Test] + public void Proponer() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Once()); + } + + [Test] + public void Proponer_y_agendar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); + } + [Test] + public void Proponer_agendar_y_cancelar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(3)); + } + + [Test] + public void Proponer_agendar_cancelar_y_reagendar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReAgendar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_agendar_cancelar_reproponer_agendar_y_confirmar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReProponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(6)); + } + + [Test] + public void Proponer_agendar_cancelar_reagendar_y_confirmar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReAgendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(5)); + } + + [Test] + public void Proponer_agendar_cancelar_y_reproponer() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.ReProponer(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_y_descartar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Descartar(); + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); + } + + [Test] + public void Proponer_agendar_cancelar_y_descartar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Cancelar(); + + workflow.Descartar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); + } + + [Test] + public void Proponer_agendar_y_confirmar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(3)); + } + + [Test] + public void Proponer_agendar_confirmar_publicar() + { + var publicador = new Mock(); + var workflow = new Workflow(publicador.Object, _eventoRepository, _personaRepository, _requestEmulator); + + workflow.Proponer(); + + workflow.Agendar(); + + workflow.Confirmar(); + + workflow.Publicar(); + + publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); + } + } +} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/hibernate.cfg.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/hibernate.cfg.xml Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,11 @@ + + + + NHibernate.Driver.SqlClientDriver + AltNetHispano + NHibernate.Dialect.MsSql2008Dialect + + NHibernate.Context.ThreadStaticSessionContext, NHibernate + NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle + + \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Repositories.Tests/packages.config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Tests/packages.config Mon Sep 19 18:18:17 2011 -0300 @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj --- a/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Mon Sep 19 18:18:17 2011 -0300 @@ -31,27 +31,9 @@ 4 - - ..\packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll - - - ..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.dll - - - ..\packages\ConfOrm.1.0.1.5\lib\Net35\ConfOrm.Shop.dll - - - ..\packages\Iesi.Collections.3.1.0.4000\lib\Net35\Iesi.Collections.dll - ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - - ..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll - - - ..\packages\NHibernate.Castle.3.1.0.4000\lib\Net35\NHibernate.ByteCode.Castle.dll - ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll @@ -74,18 +56,6 @@ - - - - - - - - - - - - @@ -93,15 +63,11 @@ - - - - @@ -116,18 +82,10 @@ {45804F1F-EB72-4F82-A227-088CAD9B785D} Agendas.Google - - {9519A43A-9D5E-4BFD-9F88-AFFC53C9973A} - Agendas.NHibernate - {28C5EBFB-EE69-4765-A880-D4DE0BC89F48} Agendas.Repositories.Memory - - {0973DF44-3B90-4D2A-B579-C64C93B6C853} - Agendas.Repositories.NHibernate - diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/App.config --- a/Agendas/trunk/src/Agendas.Tests/App.config Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/App.config Mon Sep 19 18:18:17 2011 -0300 @@ -4,10 +4,6 @@
- - - - diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrud.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrud.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -using System; -using System.Linq; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Domain.Repositories; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - public class EventoCrud - { - private readonly IEventoRepository _eventoRepository; - private readonly Func _requestEmulator; - private readonly IPersonaRepository _personaRepository; - - public EventoCrud(Func createEventoRepository, Func createPonenteRepository, Func requestEmulator) - { - _eventoRepository = createEventoRepository.Invoke(); - _personaRepository = createPonenteRepository.Invoke(); - - _requestEmulator = requestEmulator; - } - - public Guid Create() - { - using (_requestEmulator.Invoke()) - { - var ponente = new Persona("Carlos Blé") {Twitter = "carlosble"}; - _personaRepository.Save(ponente); - - var usuario = new Persona("Nelo") {Twitter = "nelopauselli"}; - _personaRepository.Save(usuario); - - var evento = Evento.Proponer("TDD - Diseño Basado en Ejemplos", ponente, string.Empty, TipoEvento.Van); - evento.Tracks.First().LogAdd(new TrackLog(TrackLogPropietario.Twitter, "Mensaje", usuario, true)); - - _eventoRepository.Save(evento); - - return evento.Id; - } - } - - public void Read() - { - Guid eventoId = Create(); - - using (_requestEmulator.Invoke()) - { - Evento van = _eventoRepository.Get(eventoId); - - Assert.IsNotNull(van); - Assert.IsNotNull(van.Ponente); - Assert.AreEqual("Carlos Blé", van.Ponente.Nombre); - - var track1 = van.Tracks.Where(t => t.Accion == Accion.Proponer).FirstOrDefault(); - Assert.IsNotNull(track1); - Assert.AreEqual(van, track1.Evento); - - Assert.AreEqual("TDD - Diseño Basado en Ejemplos", van.Titulo); - } - } - - public void Update() - { - Guid eventoId = Create(); - var fechaInicio = new DateTime(2010, 04, 17).ToUniversalTime(); - var fechaTermino = fechaInicio.AddHours(2); - - using (_requestEmulator.Invoke()) - { - Evento van = _eventoRepository.Get(eventoId); - - Assert.IsNotNull(van); - - van.CambiarTitulo("TDD & Ejemplos"); - - var otroPonente = new Persona("José"); - _personaRepository.Save(otroPonente); - - van.Actualizar(otroPonente, fechaInicio, fechaTermino, null); - - _eventoRepository.Update(van); - } - - using (_requestEmulator.Invoke()) - { - Evento van = _eventoRepository.Get(eventoId); - - Assert.IsNotNull(van); - Assert.IsNotNull(van.Ponente); - Assert.AreEqual("José", van.Ponente.Nombre); - Assert.AreEqual("TDD & Ejemplos", van.Titulo); - Assert.AreEqual(new DateTime(2010, 04, 17).ToUniversalTime(), van.FechaInicio); - Assert.AreEqual(fechaTermino, van.FechaTermino); - - var ponente1 = _personaRepository.GetByNombre("Carlos Blé"); - Assert.IsNotNull(ponente1); - - var ponente2 = _personaRepository.GetByNombre("José"); - Assert.IsNotNull(ponente2); - - Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Proponer).Count()); - Assert.AreEqual(1, van.Tracks.Where(t => t.Accion == Accion.Modificar).Count()); - } - } - - public void Delete() - { - Guid eventoId = Create(); - - using (_requestEmulator.Invoke()) - { - Evento van = _eventoRepository.Get(eventoId); - Assert.IsNotNull(van); - - _eventoRepository.Delete(van); - } - - using (_requestEmulator.Invoke()) - { - Evento van = _eventoRepository.Get(eventoId); - - Assert.IsNull(van); - - var ponente = _personaRepository.GetByNombre("Carlos Blé"); - - Assert.IsNotNull(ponente); - } - } - - public void Workflow() - { - Guid eventoId = Create(); - - using (_requestEmulator.Invoke()) - { - Evento evento = _eventoRepository.Get(eventoId); - Assert.AreEqual(EventoPropuestoState.GetInstance(), evento.Estado); - - evento.Agendar(evento.Ponente, evento.FechaInicio, evento.FechaTermino, null); - } - - using (_requestEmulator.Invoke()) - { - Evento evento = _eventoRepository.Get(eventoId); - Assert.AreEqual(EventoAgendadoState.GetInstance(), evento.Estado); - - evento.Confirmar(); - } - - using (_requestEmulator.Invoke()) - { - Evento evento = _eventoRepository.Get(eventoId); - Assert.AreEqual(EventoConfirmadoState.GetInstance(), evento.Estado); - - evento.Publicar(1, null, new TimeSpan(0, 0, 0)); - } - - using (_requestEmulator.Invoke()) - { - Evento evento = _eventoRepository.Get(eventoId); - Assert.AreEqual(EventoPublicadoState.GetInstance(), evento.Estado); - } - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudMemoryTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudMemoryTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -using System; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.Memory; -using Moq; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - [TestFixture] - public class EventoCrudMemoryTests - { - private EventoCrud _eventoCrud; - - #region SetUp - - [SetUp] - public void BorrarRepositorios() - { - EventoRepository.Clear(); - PersonaRepository.Clear(); - } - - [SetUp] - public void SetearUsuario() - { - var seguridad = new Mock(); - seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - IdentityContext.Init(seguridad.Object, new PersonaRepository()); - } - - [SetUp] - public void CreateCrud() - { - _eventoCrud = new EventoCrud(() => new EventoRepository(), ()=>new PersonaRepository(), () => new Mock().Object); - } - - #endregion - - [Test] - public void Create() - { - _eventoCrud.Create(); - } - - [Test] - public void Read() - { - _eventoCrud.Read(); - } - - [Test] - public void Update() - { - _eventoCrud.Update(); - } - - [Test] - public void Delete() - { - _eventoCrud.Delete(); - } - - [Test] - public void Workflow() - { - _eventoCrud.Workflow(); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudNhTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/EventoCrudNhTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -using Agendas.NHibernate; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.NHibernate; -using Moq; -using NHibernate; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - [TestFixture] - public class EventoCrudNhTests - { - private EventoCrud _eventoCrud; - - #region SetUp - - [SetUp] - public void BorrarRepositorios() - { - NhHelperTest.CleanDb(); - } - - [SetUp] - public void SetearUsuario() - { - var seguridad = new Mock(); - seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory())); - } - - [SetUp] - public void CreateCrud() - { - ISessionFactory sessionFactory=NhHelper.GetSessionFactory(); - _eventoCrud = new EventoCrud(() => new EventoRepository(sessionFactory), () => new PersonaRepository(sessionFactory), - () => new RequestEmulator(sessionFactory)); - } - - #endregion - - [Test] - public void Create() - { - _eventoCrud.Create(); - } - - [Test] - public void Read() - { - _eventoCrud.Read(); - } - - [Test] - public void Update() - { - _eventoCrud.Update(); - } - - [Test] - public void Delete() - { - _eventoCrud.Delete(); - } - - [Test] - public void Workflow() - { - _eventoCrud.Workflow(); - } - - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/IPersonaCrudTest.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/IPersonaCrudTest.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - public interface IPersonaCrudTest - { - [Test] - void CreateAdministrador(); - - [Test] - void ReadAdministrador(); - - [Test] - void CreateUsuario(); - - [Test] - void ReadUsuario(); - - [Test] - void Update(); - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/NhHelperTest.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/NhHelperTest.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -using Agendas.NHibernate; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - public static class NhHelperTest - { - public static void CleanDb() - { - var sf = NhHelper.GetSessionFactory(); - - var session = sf.OpenStatelessSession(); - session.CreateSQLQuery("DELETE FROM Evento").ExecuteUpdate(); - session.CreateSQLQuery("DELETE FROM Persona").ExecuteUpdate(); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrud.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrud.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -using System; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Domain.Repositories; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - //public class PatrocinadorCrud - //{ - // private readonly IPatrocinadorRepository _patrocinadorRepository; - // private readonly Func _requestEmulator; - // private byte[] _logo; - - // public PatrocinadorCrud(Func createPatrocinadorRepository, Func requestEmulator) - // { - // _patrocinadorRepository = createPatrocinadorRepository.Invoke(); - // _requestEmulator = requestEmulator; - // } - - // public Guid Create() - // { - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = new Patrocinador("APRESS"); - - // patrocinador.LoadLogo("images/apress.gif"); - // _logo = patrocinador.Logo; - - // _patrocinadorRepository.Save(patrocinador); - // return patrocinador.Id; - // } - // } - - // public void Read() - // { - // Guid patrocinadorId = Create(); - - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); - - // Assert.IsNotNull(patrocinador); - // Assert.AreEqual("APRESS", patrocinador.Nombre); - // Assert.IsNotNull(patrocinador.Logo); - // Assert.AreEqual(_logo, patrocinador.Logo); - // } - // } - - // public void Update() - // { - // Guid patrocinadorId = Create(); - - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); - // Assert.IsNotNull(patrocinador); - - // patrocinador.Nombre = "Apress"; - // } - - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); - - // Assert.IsNotNull(patrocinador); - // Assert.AreEqual("Apress", patrocinador.Nombre); - // } - // } - - // public void Delete() - // { - // Guid patrocinadorId = Create(); - - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); - // Assert.IsNotNull(patrocinador); - - // _patrocinadorRepository.Delete(patrocinador); - // } - - // using (_requestEmulator.Invoke()) - // { - // var patrocinador = _patrocinadorRepository.Get(patrocinadorId); - // Assert.IsNull(patrocinador); - // } - // } - //} -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrudMemoryTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrudMemoryTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -using System; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.Memory; -using Moq; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - //[TestFixture] - //public class PatrocinadorCrudMemoryTests - //{ - // private PatrocinadorCrud _eventoCrud; - - // #region SetUp - - // [SetUp] - // public void BorrarRepositorios() - // { - // PatrocinadorRepository.Clear(); - // } - - // [SetUp] - // public void SetearUsuario() - // { - // var seguridad = new Mock(); - // seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - // IdentityContext.Init(seguridad.Object, new PersonaRepository()); - // } - - // [SetUp] - // public void CreateCrud() - // { - // _eventoCrud = new PatrocinadorCrud(() => new PatrocinadorRepository(), () => new Mock().Object); - // } - - // #endregion - - // [Test] - // public void Create() - // { - // _eventoCrud.Create(); - // } - - // [Test] - // public void Read() - // { - // _eventoCrud.Read(); - // } - - // [Test] - // public void Update() - // { - // _eventoCrud.Update(); - // } - - // [Test] - // public void Delete() - // { - // _eventoCrud.Delete(); - // } - - //} -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrudNhTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PatrocinadorCrudNhTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -using Agendas.NHibernate; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.NHibernate; -using Moq; -using NHibernate; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - //[TestFixture] - //public class PatrocinadorCrudNhTests - //{ - // private PatrocinadorCrud _patrocinadorCrud; - - // #region SetUp - - // [SetUp] - // public void BorrarRepositorios() - // { - // NhHelperTest.CleanDb(); - // } - - // [SetUp] - // public void SetearUsuario() - // { - // var seguridad = new Mock(); - // seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - // IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory())); - // } - - // [SetUp] - // public void CreateCrud() - // { - // ISessionFactory sessionFactory = NhHelper.GetSessionFactory(); - // _patrocinadorCrud = new PatrocinadorCrud(() => new PatrocinadorRepository(sessionFactory), () => new RequestEmulator(sessionFactory)); - // } - - // #endregion - - // [Test] - // public void Create() - // { - // _patrocinadorCrud.Create(); - // } - - // [Test] - // public void Read() - // { - // _patrocinadorCrud.Read(); - // } - - // [Test] - // public void Update() - // { - // _patrocinadorCrud.Update(); - // } - - // [Test] - // public void Delete() - // { - // _patrocinadorCrud.Delete(); - // } - - //} -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrud.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrud.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -using System; -using System.Linq; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Domain.Repositories; -using AltNetHispano.Agendas.Domain.Services; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - public class PersonaCrud - { - private readonly IPersonaRepository _personaRepository; - private readonly Func _requestEmulator; - private readonly PersonaService _personaService; - private readonly IEventoRepository _eventoRepository; - - public PersonaCrud(Func createpersonaRepository, Func requestEmulator, Func createEventoRespository) - { - _personaRepository = createpersonaRepository.Invoke(); - _eventoRepository = createEventoRespository.Invoke(); - _personaService = new PersonaService(_personaRepository, _eventoRepository); - _requestEmulator = requestEmulator; - } - - public Guid CreateAdministrador() - { - Guid id; - using (_requestEmulator.Invoke()) - { - var r = _personaService.Add("Nelo Pauselli", "nelopauselli", "nelopauselli@gmail.com", "http://nelopauselli.blogspot.com", null); - Assert.AreEqual("Nelo Pauselli", r.Nombre); - Assert.AreNotEqual(Guid.Empty, r.Id); - - id = r.Id; - } - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.GetByNombre("Nelo Pauselli"); - Assert.IsNotNull(persona); - Assert.AreEqual(id, persona.Id); - return persona.Id; - } - } - - public void ReadAdministrador() - { - Guid personaId = CreateAdministrador(); - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - - Assert.IsNotNull(persona); - Assert.AreEqual("Nelo Pauselli", persona.Nombre); - Assert.AreEqual("nelopauselli", persona.Twitter); - Assert.AreEqual("nelopauselli@gmail.com", persona.Mail); - Assert.AreEqual("http://nelopauselli.blogspot.com", persona.Blog); - - Assert.IsTrue(persona.Cuentas.Any()); - Assert.AreEqual("nelopauselli", persona.Cuentas.First().LogonName); - Assert.AreEqual(IdentityProviderEnum.Twitter, persona.Cuentas.First().IdentityProvider); - - Assert.IsTrue(persona.Roles.Any()); - Assert.IsTrue(persona.Roles.Contains(Roles.Usuario)); - Assert.IsTrue(persona.Roles.Contains(Roles.Administrador)); - } - } - - public Guid CreateUsuario() - { - using (_requestEmulator.Invoke()) - { - _personaService.Add("Pablo Morales", "pablomorales", "pablomorales@gmail.com", "http://pablomorales.blogspot.com", new[]{Roles.Usuario}); - } - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.GetByNombre("Pablo Morales"); - Assert.IsNotNull(persona); - return persona.Id; - } - } - - public void ReadUsuario() - { - Guid personaId = CreateUsuario(); - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - - Assert.IsNotNull(persona); - Assert.AreEqual("Pablo Morales", persona.Nombre); - Assert.AreEqual("pablomorales", persona.Twitter); - Assert.AreEqual("pablomorales@gmail.com", persona.Mail); - Assert.AreEqual("http://pablomorales.blogspot.com", persona.Blog); - - Assert.IsTrue(persona.Cuentas.Any()); - Assert.AreEqual("pablomorales", persona.Cuentas.First().LogonName); - Assert.AreEqual(IdentityProviderEnum.Twitter, persona.Cuentas.First().IdentityProvider); - - Assert.IsTrue(persona.Roles.Any()); - Assert.IsTrue(persona.Roles.Contains(Roles.Usuario)); - Assert.IsFalse(persona.Roles.Contains(Roles.Administrador)); - } - } - - public void Update() - { - Guid personaId = CreateAdministrador(); - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - Assert.IsNotNull(persona); - - persona.Nombre = "Nelo Mariano Pauselli"; - } - - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - - Assert.IsNotNull(persona); - Assert.AreEqual("Nelo Mariano Pauselli", persona.Nombre); - } - } - public void Delete() - { - var personaId = CreateUsuario(); - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - Assert.IsNotNull(persona); - _personaService.Delete(personaId); - } - using (_requestEmulator.Invoke()) - { - var persona = _personaRepository.Get(personaId); - Assert.IsNull(persona); - } - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrudMemoryTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrudMemoryTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -using System; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.Memory; -using Moq; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - [TestFixture] - public class PersonaCrudMemoryTests : IPersonaCrudTest - { - private PersonaCrud _test; - - #region SetUp - - [SetUp] - public void BorrarRepositorios() - { - PersonaRepository.Clear(); - } - - [SetUp] - public void SetearUsuario() - { - var seguridad = new Mock(); - seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - IdentityContext.Init(seguridad.Object, new PersonaRepository()); - } - - [SetUp] - public void CreateCrud() - { - _test = new PersonaCrud(() => new PersonaRepository(), () => new Mock().Object, - () => new EventoRepository()); - } - - #endregion - - [Test] - public void CreateAdministrador() - { - _test.CreateAdministrador(); - } - - [Test] - public void ReadAdministrador() - { - _test.ReadAdministrador(); - } - - [Test] - public void CreateUsuario() - { - _test.CreateUsuario(); - } - - [Test] - public void ReadUsuario() - { - _test.ReadUsuario(); - } - - [Test] - public void Update() - { - _test.Update(); - } - - [Test] - public void Delete() - { - _test.Delete(); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrudNhTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/PersonaCrudNhTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -using Agendas.NHibernate; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Repositories.NHibernate; -using Moq; -using NHibernate; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - [TestFixture] - public class PersonaCrudNhTests : IPersonaCrudTest - { - private PersonaCrud _test; - - #region SetUp - - [SetUp] - public void BorrarRepositorios() - { - NhHelperTest.CleanDb(); - } - - [SetUp] - public void SetearUsuario() - { - var seguridad = new Mock(); - seguridad.Setup(s => s.GetUserName()).Returns("neluz"); - IdentityContext.Init(seguridad.Object, new PersonaRepository(NhHelper.GetSessionFactory())); - } - - [SetUp] - public void CreateCrud() - { - ISessionFactory sessionFactory = NhHelper.GetSessionFactory(); - _test = new PersonaCrud(() => new PersonaRepository(sessionFactory), () => new RequestEmulator(sessionFactory), - () => new EventoRepository(sessionFactory)); - } - - #endregion - - [Test] - public void CreateAdministrador() - { - _test.CreateAdministrador(); - } - - [Test] - public void ReadAdministrador() - { - _test.ReadAdministrador(); - } - - [Test] - public void CreateUsuario() - { - _test.CreateUsuario(); - } - - [Test] - public void ReadUsuario() - { - _test.ReadUsuario(); - } - - [Test] - public void Update() - { - _test.Update(); - } - - [Test] - public void Delete() - { - _test.Delete(); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/RequestEmulator.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/RequestEmulator.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -using System; -using NHibernate; -using NHibernate.Context; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - public class RequestEmulator : IDisposable - { - private readonly ISession _session; - - public RequestEmulator(ISessionFactory sessionFactory) - { - _session = sessionFactory.OpenSession(); - CurrentSessionContext.Bind(_session); - } - - public void Dispose() - { - _session.Flush(); - _session.Close(); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Cruds/SchemaNhTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Cruds/SchemaNhTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -using System; -using System.Xml; -using System.Xml.Serialization; -using Agendas.NHibernate; -using NHibernate.Cfg.MappingSchema; -using NHibernate.Tool.hbm2ddl; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Cruds -{ - [TestFixture] - public class SchemaNhTests - { - [Test] - public void ValidateSchema() - { - var cfg = NhHelper.GetConfiguration(); - - var schemaValidator = new SchemaValidator(cfg); - schemaValidator.Validate(); - } - - [Test] - public void BuildSessionFactory() - { - var cfg = NhHelper.GetConfiguration(); - - var sessionfactory = cfg.BuildSessionFactory(); - - Assert.IsNotNull(sessionfactory); - } - - [Test] - public void ShowMapping() - { - var mapping = NhHelper.GetMapping(); - - var setting = new XmlWriterSettings { Indent = true }; - - var serializer = new XmlSerializer(typeof(HbmMapping)); - - var xw = XmlWriter.Create(Console.Out, setting); - - serializer.Serialize(xw, mapping); - } - - [Test] - public void LimpiarDb() - { - NhHelperTest.CleanDb(); - - var sf = NhHelper.GetSessionFactory(); - - var session = sf.OpenSession(); - - var query = session.CreateQuery("from System.Object"); - - Assert.IsEmpty(query.List()); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/EventoStateTests.cs --- a/Agendas/trunk/src/Agendas.Tests/EventoStateTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/EventoStateTests.cs Mon Sep 19 18:18:17 2011 -0300 @@ -1,6 +1,6 @@ using System.Linq; -using Agendas.NHibernate; using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; using NUnit.Framework; namespace AltNetHispano.Agendas.Tests @@ -11,7 +11,7 @@ [Test] public void Check_all() { - var definidos = EventoStateType.All; + var definidos = EventoStateRepository.All; var types = typeof (EventoState).Assembly.GetTypes(); diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Workflows/Workflow.cs --- a/Agendas/trunk/src/Agendas.Tests/Workflows/Workflow.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -using System; -using System.Linq; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Domain.Repositories; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Workflows -{ - internal class Workflow - { - private readonly Func _requestEmulator; - private readonly Agenda _agenda; - private readonly IEventoRepository _eventoRepository; - private Guid _eventoId; - - public Workflow(IPublicador publicador, IEventoRepository eventoRepository, IPersonaRepository personaRepository, - Func requestEmulator) - { - _requestEmulator = requestEmulator; - _eventoRepository = eventoRepository; - _agenda = new Agenda(publicador, eventoRepository, personaRepository); - } - - public void Proponer() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.Proponer("SOLID", TestsHelper.GetOrCreatePonente("Jorge"), null, TipoEvento.Van); - Assert.IsTrue(resultado.Succeful); - } - - GetId(); - } - - - public void Agendar() - { - using (_requestEmulator.Invoke()) - { - var fechaInicio = DateTime.Today.AddDays(5).ToUniversalTime(); - var fechaTermino = fechaInicio.AddHours(2); - var resultado = _agenda.Agendar("SOLID", TestsHelper.GetOrCreatePonente("Jorge"), fechaInicio, fechaTermino, null, - TipoEvento.Van); - Assert.IsTrue(resultado.Succeful); - } - - GetId(); - } - - private void GetId() - { - using (_requestEmulator.Invoke()) - { - var evento = _eventoRepository.GetActivos().SingleOrDefault(); - Assert.IsNotNull(evento); - _eventoId = evento.Id; - } - } - - public void Confirmar() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.Confirmar(_eventoId); - Assert.IsTrue(resultado.Succeful); - } - } - - public void Publicar() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.Publicar(_eventoId, 1, "http://www.altnethispano.org/", new TimeSpan(2, 11, 0)); - Assert.IsTrue(resultado.Succeful); - } - } - - public void Cancelar() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.Cancelar(_eventoId); - Assert.IsTrue(resultado.Succeful); - } - } - - public void Descartar() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.Descartar(_eventoId); - Assert.IsTrue(resultado.Succeful); - } - } - - public void ReProponer() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.ReProponer(_eventoId); - Assert.IsTrue(resultado.Succeful); - } - } - - public void ReAgendar() - { - using (_requestEmulator.Invoke()) - { - var resultado = _agenda.ReAgendar(_eventoId); - Assert.IsTrue(resultado.Succeful); - } - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowMemoryTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowMemoryTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; -using AltNetHispano.Agendas.Domain; -using Moq; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Workflows -{ - [TestFixture] - public class WorkflowMemoryTests : TestBase - { - private Mock _publicador; - private Workflow _workflow; - - [SetUp] - public void InitPublicador() - { - _publicador = new Mock(); - _workflow = new Workflow(_publicador.Object, DefaultEventoRepository, DefaultPersonaRepository, () => new Mock().Object); - } - - [Test] - public void Proponer() - { - _workflow.Proponer(); - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Once()); - } - - [Test] - public void Proponer_y_agendar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); - } - - [Test] - public void Proponer_agendar_y_cancelar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _publicador.Verify(p=>p.Publicar(It.IsAny>()), Times.Exactly(3)); - } - - [Test] - public void Proponer_agendar_cancelar_y_reagendar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReAgendar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_agendar_cancelar_reproponer_agendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReProponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(6)); - } - - [Test] - public void Proponer_agendar_cancelar_reagendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReAgendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(5)); - } - - [Test] - public void Proponer_agendar_cancelar_y_reproponer() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReProponer(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_y_descartar() - { - _workflow.Proponer(); - - _workflow.Descartar(); - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); - } - - [Test] - public void Proponer_agendar_cancelar_y_descartar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.Descartar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_agendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(3)); - } - - [Test] - public void Proponer_agendar_confirmar_publicar() - { - const string urlWiki = "http://www.altnethispano.org/wiki/van-2010-10-21-mono-cecil.ashx"; - - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _workflow.Publicar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowNhTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Workflows/WorkflowNhTests.cs Tue Sep 13 09:01:58 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -using System.Collections.Generic; -using Agendas.NHibernate; -using AltNetHispano.Agendas.Domain; -using AltNetHispano.Agendas.Tests.Cruds; -using Moq; -using NUnit.Framework; - -namespace AltNetHispano.Agendas.Tests.Workflows -{ - [TestFixture] - public class WorkflowNhTests : TestBase - { - private Mock _publicador; - private Workflow _workflow; - - [SetUp] - public void InitPublicador() - { - _publicador = new Mock(); - _workflow = new Workflow(_publicador.Object, DefaultEventoRepository, DefaultPersonaRepository, () => new RequestEmulator(NhHelper.GetSessionFactory())); - } - - [Test] - public void Proponer() - { - _workflow.Proponer(); - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Once()); - } - - [Test] - public void Proponer_y_agendar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); - } - [Test] - public void Proponer_agendar_y_cancelar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(3)); - } - - [Test] - public void Proponer_agendar_cancelar_y_reagendar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReAgendar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_agendar_cancelar_reproponer_agendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReProponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(6)); - } - - [Test] - public void Proponer_agendar_cancelar_reagendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReAgendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(5)); - } - - [Test] - public void Proponer_agendar_cancelar_y_reproponer() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.ReProponer(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_y_descartar() - { - _workflow.Proponer(); - - _workflow.Descartar(); - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(2)); - } - - [Test] - public void Proponer_agendar_cancelar_y_descartar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Cancelar(); - - _workflow.Descartar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - - [Test] - public void Proponer_agendar_y_confirmar() - { - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(3)); - } - - [Test] - public void Proponer_agendar_confirmar_publicar() - { - const string urlWiki = "http://www.altnethispano.org/wiki/van-2010-10-21-mono-cecil.ashx"; - - _workflow.Proponer(); - - _workflow.Agendar(); - - _workflow.Confirmar(); - - _workflow.Publicar(); - - _publicador.Verify(p => p.Publicar(It.IsAny>()), Times.Exactly(4)); - } - } -} \ No newline at end of file diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/Agendas.sln --- a/Agendas/trunk/src/Agendas.sln Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/Agendas.sln Mon Sep 19 18:18:17 2011 -0300 @@ -40,6 +40,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Web.Tests", "Agendas.Web.Tests\Agendas.Web.Tests.csproj", "{10FECBBD-F07F-4721-87DA-D3184CF86C90}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Repositories.Tests", "Agendas.Repositories.Tests\Agendas.Repositories.Tests.csproj", "{BFCD197C-01D5-4645-B0DF-053867E16FDE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -110,6 +112,10 @@ {10FECBBD-F07F-4721-87DA-D3184CF86C90}.Debug|Any CPU.Build.0 = Debug|Any CPU {10FECBBD-F07F-4721-87DA-D3184CF86C90}.Release|Any CPU.ActiveCfg = Release|Any CPU {10FECBBD-F07F-4721-87DA-D3184CF86C90}.Release|Any CPU.Build.0 = Release|Any CPU + {BFCD197C-01D5-4645-B0DF-053867E16FDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFCD197C-01D5-4645-B0DF-053867E16FDE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFCD197C-01D5-4645-B0DF-053867E16FDE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFCD197C-01D5-4645-B0DF-053867E16FDE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff -r 37ddf81333d3 -r 68b09c30b0d2 Agendas/trunk/src/install packages.bat --- a/Agendas/trunk/src/install packages.bat Tue Sep 13 09:01:58 2011 -0300 +++ b/Agendas/trunk/src/install packages.bat Mon Sep 19 18:18:17 2011 -0300 @@ -1,5 +1,6 @@ ..\tools\nuget i Agendas.Tests\packages.config -o packages ..\tools\nuget i Agendas.Repositories.NHibernate\packages.config -o packages +..\tools\nuget i Agendas.Repositories.Tests\packages.config -o packages ..\tools\nuget i Agendas.NHibernate\packages.config -o packages ..\tools\nuget i Agendas.Web\packages.config -o packages ..\tools\nuget i Agendas.Twitter\packages.config -o packages