Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Tests/Blog/PublicadorTests.cs @ 109:6bd9be78caa0
Merge
author | Nelo@Kenia.neluz.int |
---|---|
date | Tue, 07 Jun 2011 23:21:07 -0300 |
parents | 1d820f17fc75 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Tests/Blog/PublicadorTests.cs Tue Jun 07 23:21:07 2011 -0300 @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Agendas.Blog; +using Agendas.Blog.Impl; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Repositories.Memory; +using Moq; +using NUnit.Framework; + +namespace AltNetHispano.Agendas.Tests.Blog +{ + [TestFixture] + public class PublicadorTests + { + [SetUp] + public void SetearUsuario() + { + var seguridad = new Mock<ISeguridad>(); + seguridad.Setup(s => s.GetUserName()).Returns("neluz"); + IdentityContext.Init(seguridad.Object, new PersonaRepository()); + } + + [Test] + public void El_publicador_debe_disparar_los_writers_segun_la_accion_de_cada_track() + { + //var eventoAgendar = Evento.Agendar(null, null, DateTime.MinValue, null); + //var eventoPublicar = Evento.Agendar(null, null, DateTime.MinValue, null); + + var trackAgendar = new Track(null, Accion.Agendar); + var trackPublicar = new Track(null, Accion.Publicar); + + var agendarPostWriter = new Mock<IPostWriter>(); + agendarPostWriter.Setup(writer => writer.WritePost(trackAgendar)); + + var publicarPostWriter = new Mock<IPostWriter>(); + publicarPostWriter.Setup(writer => writer.WritePost(trackPublicar)); + + var factory = new Mock<IPostWriterFactory>(); + factory.Setup(f => f.GetPostWriter(Accion.Agendar)).Returns(agendarPostWriter.Object); + factory.Setup(f => f.GetPostWriter(Accion.Publicar)).Returns(publicarPostWriter.Object); + + var publicador = new BlogPublicador(factory.Object); + publicador.Publicar(new List<Track> + { + trackAgendar, + trackPublicar + }); + + factory.Verify(f => f.GetPostWriter(Accion.Agendar), Times.Once()); + factory.Verify(f => f.GetPostWriter(Accion.Publicar), Times.Once()); + + agendarPostWriter.Verify(pw => pw.WritePost(trackAgendar), Times.Once()); + publicarPostWriter.Verify(pw => pw.WritePost(trackPublicar), Times.Once()); + } + } +}