# HG changeset patch # User nelopauselli # Date 1295736632 10800 # Node ID 6bb4ab4c0611e8e3e9a449f0dbc588e48014f597 # Parent 3f7dbb633b717a8ae8db6e9daacc2a46c44427cd Tests de Crud para repositorio de Vans diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/Agenda.cs --- a/Agendas/trunk/src/Agendas.Domain/Agenda.cs Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Agenda.cs Sat Jan 22 19:50:32 2011 -0300 @@ -1,22 +1,33 @@ -using AltNetHispano.Agendas.Domain.Repositories; +using System; +using AltNetHispano.Agendas.Domain.Repositories; namespace AltNetHispano.Agendas.Domain { public class Agenda { private readonly IPublicador _publicador; + private readonly IRecordador _recordador; private readonly IEventoRepository _eventoRepository; - public Agenda(IPublicador publicador, IEventoRepository eventoRepository) + public Agenda(IPublicador publicador, IRecordador recordador, IEventoRepository eventoRepository) { _publicador = publicador; + _recordador = recordador; _eventoRepository = eventoRepository; } public void Publicar(Evento evento) { _eventoRepository.Save(evento); - _publicador.Publicar(evento); + + if (_publicador != null) + _publicador.Publicar(evento); + } + + public void Recordar(Evento evento) + { + if (_recordador != null) + _recordador.Recordar(evento); } } } \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj --- a/Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Agendas.Domain.csproj Sat Jan 22 19:50:32 2011 -0300 @@ -44,6 +44,7 @@ + diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/Evento.cs --- a/Agendas/trunk/src/Agendas.Domain/Evento.cs Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Evento.cs Sat Jan 22 19:50:32 2011 -0300 @@ -1,6 +1,9 @@ -namespace AltNetHispano.Agendas.Domain +using System; + +namespace AltNetHispano.Agendas.Domain { public class Evento { + public Guid Id { get; set; } } } \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/IRecordador.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Domain/IRecordador.cs Sat Jan 22 19:50:32 2011 -0300 @@ -0,0 +1,7 @@ +namespace AltNetHispano.Agendas.Domain +{ + public interface IRecordador + { + void Recordar(Evento evento); + } +} \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs --- a/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Repositories/IEventoRepository.cs Sat Jan 22 19:50:32 2011 -0300 @@ -1,7 +1,21 @@ -namespace AltNetHispano.Agendas.Domain.Repositories +using System; + +namespace AltNetHispano.Agendas.Domain.Repositories { public interface IEventoRepository { void Save(Evento evento); + void Delete(Evento evento); + void Update(Evento evento); + } + + public interface IVanRepository : IEventoRepository + { + Van Get(Guid vanId); + } + + public interface ICafeRepository : IEventoRepository + { + Cafe Get(Guid vanId); } } \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Domain/Van.cs --- a/Agendas/trunk/src/Agendas.Domain/Van.cs Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Van.cs Sat Jan 22 19:50:32 2011 -0300 @@ -1,6 +1,18 @@ -namespace AltNetHispano.Agendas.Domain +using System; +using System.Collections.Generic; + +namespace AltNetHispano.Agendas.Domain { public class Van : Evento { + public string Titulo { get; set; } + + public string Ponente { get; set; } + + public DateTime Fecha { get; set; } + + public string Sintesis { get; set; } + + public IList Enlaces { get; set; } } } \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Repositories.Memory/Agendas.Repositories.Memory.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/Agendas.Repositories.Memory.csproj Sat Jan 22 19:50:32 2011 -0300 @@ -0,0 +1,61 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {28C5EBFB-EE69-4765-A880-D4DE0BC89F48} + Library + Properties + Agendas.Repositories.Memory + Agendas.Repositories.Memory + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} + Agendas.Domain + + + + + \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Repositories.Memory/Class1.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/Class1.cs Sat Jan 22 19:50:32 2011 -0300 @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Agendas.Repositories.Memory +{ + public class Class1 + { + } +} diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Repositories.Memory/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/Properties/AssemblyInfo.cs Sat Jan 22 19:50:32 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.Memory")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Agendas.Repositories.Memory")] +[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("b5eed6a9-cfdc-4f27-8629-bcfa976ac30a")] + +// 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 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Repositories.Memory/VanRepositoryMemory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/VanRepositoryMemory.cs Sat Jan 22 19:50:32 2011 -0300 @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; + +namespace Agendas.Repositories.Memory +{ + public class VanRepositoryMemory : IVanRepository + { + private static readonly IDictionary Vans = new Dictionary(); + + public void Save(Evento evento) + { + if (Guid.Empty.Equals(evento.Id)) + { + evento.Id = Guid.NewGuid(); + Vans.Add(evento.Id, evento); + } + } + + public void Update(Evento evento) + { + //nada que hacer en este método para este repositorio + } + + public Van Get(Guid vanId) + { + Evento evento; + return Vans.TryGetValue(vanId, out evento) ? evento as Van : null; + } + + public void Delete(Evento evento) + { + Vans.Remove(evento.Id); + } + + } +} \ No newline at end of file diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Tests/AgendaTests.cs --- a/Agendas/trunk/src/Agendas.Tests/AgendaTests.cs Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/AgendaTests.cs Sat Jan 22 19:50:32 2011 -0300 @@ -9,50 +9,44 @@ public class AgendaTests { [Test] - public void PublicarVan() + public void Publicar_van() { var publicador = new Mock(); - publicador.Setup(p => p.Publicar(It.IsAny())).Verifiable(); - var eventoRepository = new Mock(); - var agenda = new Agenda(publicador.Object, eventoRepository.Object); + var agenda = new Agenda(publicador.Object, null, eventoRepository.Object); var van = new Van(); agenda.Publicar(van); publicador.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); + eventoRepository.Verify(r => r.Save(It.IsAny()), Times.Exactly(1)); } [Test] - public void PublicarCafe() + public void Publicar_cafe() { var publicador = new Mock(); - publicador.Setup(p => p.Publicar(It.IsAny())).Verifiable(); - var eventoRepository = new Mock(); - var agenda = new Agenda(publicador.Object, eventoRepository.Object); + var agenda = new Agenda(publicador.Object, null, eventoRepository.Object); var cafe = new Cafe(); agenda.Publicar(cafe); publicador.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); - + eventoRepository.Verify(r => r.Save(It.IsAny()), Times.Exactly(1)); } [Test] - public void PublicarComposite() + public void Publicar_van_multiples_publicadores() { var publicador1 = new Mock(); - publicador1.Setup(p => p.Publicar(It.IsAny())).Verifiable(); - var publicador2 = new Mock(); - publicador2.Setup(p => p.Publicar(It.IsAny())).Verifiable(); var eventoRepository = new Mock(); - var agenda = new Agenda(new CompositePublicador (new[] { publicador1.Object, publicador2.Object } ), eventoRepository.Object); + var agenda = new Agenda(new CompositePublicador (new[] { publicador1.Object, publicador2.Object } ), null, eventoRepository.Object); var cafe = new Cafe(); agenda.Publicar(cafe); @@ -60,5 +54,27 @@ publicador1.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); publicador2.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); } + + [Test] + public void Publicar_y_recordar_van() + { + var publicador1 = new Mock(); + var publicador2 = new Mock(); + var recordador1 = new Mock(); + + var eventoRepository = new Mock(); + + var agenda = new Agenda(new CompositePublicador(new[] { publicador1.Object, publicador2.Object }), recordador1.Object, eventoRepository.Object); + + var van = new Van(); + agenda.Publicar(van); + + agenda.Recordar(van); + + publicador1.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); + publicador2.Verify(p => p.Publicar(It.IsAny()), Times.Exactly(1)); + recordador1.Verify(r => r.Recordar(It.IsAny()), Times.Exactly(1)); + + } } } diff -r 3f7dbb633b71 -r 6bb4ab4c0611 Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj --- a/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Sat Jan 22 17:13:46 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/Agendas.Tests.csproj Sat Jan 22 19:50:32 2011 -0300 @@ -47,6 +47,7 @@ + @@ -58,6 +59,10 @@ {45804F1F-EB72-4F82-A227-088CAD9B785D} Agendas.Google + + {28C5EBFB-EE69-4765-A880-D4DE0BC89F48} + Agendas.Repositories.Memory +