Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Tests/Blog/PublicadorTests.cs @ 99:3027c64344bd
agregado de llamadas a web service para crear posts en el blog de la comunidad
agregado de tests sobre el publicador de blogs
agregado de tests sobre el adapter del web service
author | jorge.rowies |
---|---|
date | Sat, 04 Jun 2011 22:33:05 -0300 |
parents | |
children | cc91817a4206 |
line wrap: on
line source
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Agendas.Blog; using Agendas.Blog.Impl; using AltNetHispano.Agendas.Domain; 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.Current = seguridad.Object; } [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 agendarPostWriter = new Mock<IPostWriter>(); agendarPostWriter.Setup(writer => writer.WritePost(eventoAgendar)); var publicarPostWriter = new Mock<IPostWriter>(); publicarPostWriter.Setup(writer => writer.WritePost(eventoPublicar)); 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> { new Track(eventoAgendar, Accion.Agendar), new Track(eventoPublicar, Accion.Publicar) }); factory.Verify(f => f.GetPostWriter(Accion.Agendar), Times.Once()); factory.Verify(f => f.GetPostWriter(Accion.Publicar), Times.Once()); agendarPostWriter.Verify(pw => pw.WritePost(eventoAgendar), Times.Once()); publicarPostWriter.Verify(pw => pw.WritePost(eventoPublicar), Times.Once()); } } }